OLD | NEW |
(Empty) | |
| 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 @TestOn("vm") |
| 6 library analyzer_cli.test.strong_mode; |
| 7 |
| 8 import 'dart:io'; |
| 9 |
| 10 import 'package:analyzer_cli/src/driver.dart' show Driver, errorSink, outSink; |
| 11 import 'package:path/path.dart' as path; |
| 12 import 'package:test/test.dart'; |
| 13 |
| 14 import 'driver_test.dart'; |
| 15 import 'utils.dart'; |
| 16 |
| 17 /// End-to-end test for --strong checking. |
| 18 /// |
| 19 /// Most strong mode tests are in Analyzer, but this verifies the option is |
| 20 /// working and producing extra errors as expected. |
| 21 /// |
| 22 /// Generally we don't want a lot of cases here as it requires spinning up a |
| 23 /// full analysis context. |
| 24 void main() { |
| 25 group('--strong', () { |
| 26 StringSink savedOutSink, savedErrorSink; |
| 27 int savedExitCode; |
| 28 setUp(() { |
| 29 savedOutSink = outSink; |
| 30 savedErrorSink = errorSink; |
| 31 savedExitCode = exitCode; |
| 32 outSink = new StringBuffer(); |
| 33 errorSink = new StringBuffer(); |
| 34 }); |
| 35 tearDown(() { |
| 36 outSink = savedOutSink; |
| 37 errorSink = savedErrorSink; |
| 38 exitCode = savedExitCode; |
| 39 }); |
| 40 |
| 41 test('produces stricter errors', () async { |
| 42 var testPath = path.join(testDirectory, 'data/strong_example.dart'); |
| 43 new Driver().start(['--options', emptyOptionsFile, '--strong', testPath]); |
| 44 |
| 45 expect(exitCode, 3); |
| 46 var stdout = outSink.toString(); |
| 47 expect(stdout, contains('[error] Invalid override')); |
| 48 expect(stdout, contains('[error] Type check failed')); |
| 49 expect(stdout, contains('2 errors found.')); |
| 50 expect(errorSink.toString(), ''); |
| 51 }); |
| 52 }); |
| 53 } |
OLD | NEW |