|
| 1 | +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 | +// for details. All rights reserved. Use of this source code is governed by a |
| 3 | +// BSD-style license that can be found in the LICENSE file. |
| 4 | + |
| 5 | +library dartdoc.io_utils_test; |
| 6 | + |
| 7 | +import 'package:test/test.dart'; |
| 8 | + |
| 9 | +import '../tool/grind.dart' hide test; |
| 10 | + |
| 11 | +void main() { |
| 12 | + group('printWarningDelta', () { |
| 13 | + WarningsCollection original, current; |
| 14 | + WarningsCollection originalWithDirs, currentWithDirs; |
| 15 | + setUp(() { |
| 16 | + original = |
| 17 | + new WarningsCollection('/a/tempdir', '/pubcache/path', 'oldbranch'); |
| 18 | + original.add('originalwarning'); |
| 19 | + original.add('morewarning'); |
| 20 | + original.add('duplicateoriginalwarning'); |
| 21 | + original.add('duplicateoriginalwarning'); |
| 22 | + current = |
| 23 | + new WarningsCollection('/a/tempdir2', '/pubcache/path2', 'current'); |
| 24 | + current.add('newwarning'); |
| 25 | + current.add('morewarning'); |
| 26 | + current.add('duplicateoriginalwarning'); |
| 27 | + originalWithDirs = new WarningsCollection( |
| 28 | + '/a/tempdirFOO', '/pubcache/pathFOO', 'DirsOriginal'); |
| 29 | + originalWithDirs.add( |
| 30 | + 'originalWarning found in /a/tempdirFOO/some/subdir/program.dart!!!!'); |
| 31 | + originalWithDirs.add( |
| 32 | + 'another originalWarning found in /pubcache/pathFOO/some/package/lib/thingy.dart!!!'); |
| 33 | + originalWithDirs.add( |
| 34 | + 'insufficent exclamation mark warning found in /pubcache/pathFOO/some/package/lib/thingy.dart.'); |
| 35 | + originalWithDirs.add( |
| 36 | + 'another originalWarning found in /a/tempdirFOO/some/subdir/program.dart'); |
| 37 | + currentWithDirs = new WarningsCollection( |
| 38 | + '/a/tempdirBAR', '/pubcache/pathBAR', 'DirsCurrent'); |
| 39 | + currentWithDirs.add( |
| 40 | + 'originalWarning found in /a/tempdirBAR/some/subdir/program.dart!!!!'); |
| 41 | + currentWithDirs.add( |
| 42 | + 'another originalWarning found in /pubcache/pathBAR/some/package/lib/thingy.dart!!!'); |
| 43 | + currentWithDirs.add( |
| 44 | + 'insufficent exclamation mark warning found in /pubcache/pathBAR/some/package/lib/thingy.dart.'); |
| 45 | + currentWithDirs.add( |
| 46 | + 'another originalWarning found in /a/tempdirBAR/some/other/subdir/program.dart'); |
| 47 | + }); |
| 48 | + |
| 49 | + test('verify that paths are substituted when comparing warnings', () { |
| 50 | + expect( |
| 51 | + originalWithDirs.getPrintableWarningDelta( |
| 52 | + 'Dirs diff title', currentWithDirs), |
| 53 | + equals( |
| 54 | + '*** Dirs diff title : 1 warnings from DirsOriginal, missing in DirsCurrent:\n' |
| 55 | + 'another originalWarning found in /a/tempdirFOO/some/subdir/program.dart\n' |
| 56 | + '*** Dirs diff title : 1 new warnings in DirsCurrent, missing in DirsOriginal\n' |
| 57 | + 'another originalWarning found in /a/tempdirBAR/some/other/subdir/program.dart\n' |
| 58 | + '*** Dirs diff title : Difference in warning output found for 2 warnings (5 warnings found)"\n')); |
| 59 | + }); |
| 60 | + |
| 61 | + test('verify output of printWarningDelta', () { |
| 62 | + expect( |
| 63 | + original.getPrintableWarningDelta('Diff Title', current), |
| 64 | + equals( |
| 65 | + '*** Diff Title : 1 warnings from oldbranch, missing in current:\n' |
| 66 | + 'originalwarning\n' |
| 67 | + '*** Diff Title : 1 new warnings in current, missing in oldbranch\n' |
| 68 | + 'newwarning\n' |
| 69 | + '*** Diff Title : Identical warning quantity changed\n' |
| 70 | + '* Appeared 2 times in oldbranch, 1 in current:\n' |
| 71 | + 'duplicateoriginalwarning\n' |
| 72 | + '*** Diff Title : Difference in warning output found for 3 warnings (4 warnings found)"\n')); |
| 73 | + }); |
| 74 | + |
| 75 | + test('verify output when nothing changes', () { |
| 76 | + expect( |
| 77 | + original.getPrintableWarningDelta('Diff Title 2', original), |
| 78 | + equals( |
| 79 | + '*** Diff Title 2 : No difference in warning output from oldbranch to oldbranch (3 warnings found)\n')); |
| 80 | + }); |
| 81 | + }); |
| 82 | +} |
0 commit comments