OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library analyzer_cli.test.strong_mode; | 5 library analyzer_cli.test.strong_mode; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
9 import 'package:analyzer_cli/src/driver.dart' show Driver, errorSink, outSink; | 9 import 'package:analyzer_cli/src/driver.dart' show outSink; |
10 import 'package:path/path.dart' as path; | |
11 import 'package:test/test.dart'; | 10 import 'package:test/test.dart'; |
| 11 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
12 | 12 |
13 import 'driver_test.dart'; | 13 import 'driver_test.dart'; |
14 import 'utils.dart'; | 14 |
| 15 main() { |
| 16 // TODO(pq): fix tests to run safely on the bots |
| 17 // https://github.com/dart-lang/sdk/issues/25001 |
| 18 // defineReflectiveTests(StrongModeTest); |
| 19 } |
15 | 20 |
16 /// End-to-end test for --strong checking. | 21 /// End-to-end test for --strong checking. |
17 /// | 22 /// |
18 /// Most strong mode tests are in Analyzer, but this verifies the option is | 23 /// Most strong mode tests are in Analyzer, but this verifies the option is |
19 /// working and producing extra errors as expected. | 24 /// working and producing extra errors as expected. |
20 /// | 25 /// |
21 /// Generally we don't want a lot of cases here as it requires spinning up a | 26 /// Generally we don't want a lot of cases here as it requires spinning up a |
22 /// full analysis context. | 27 /// full analysis context. |
23 /// | 28 @reflectiveTest |
24 // TODO(pq): fix tests to run safely on the bots | 29 class StrongModeTest extends BaseTest { |
25 // https://github.com/dart-lang/sdk/issues/25001 | 30 test_producesStricterErrors() async { |
26 main() {} | 31 await drive('data/strong_example.dart', args: ['--strong']); |
27 not_main() { | |
28 group('--strong', () { | |
29 StringSink savedOutSink, savedErrorSink; | |
30 int savedExitCode; | |
31 setUp(() { | |
32 savedOutSink = outSink; | |
33 savedErrorSink = errorSink; | |
34 savedExitCode = exitCode; | |
35 outSink = new StringBuffer(); | |
36 errorSink = new StringBuffer(); | |
37 }); | |
38 tearDown(() { | |
39 outSink = savedOutSink; | |
40 errorSink = savedErrorSink; | |
41 exitCode = savedExitCode; | |
42 }); | |
43 | 32 |
44 test('produces stricter errors', () async { | 33 expect(exitCode, 3); |
45 var testPath = path.join(testDirectory, 'data/strong_example.dart'); | 34 var stdout = bulletToDash(outSink); |
46 new Driver(isTesting: true) | 35 expect(stdout, contains('error - Invalid override')); |
47 .start(['--options', emptyOptionsFile, '--strong', testPath]); | 36 expect(stdout, contains('error - The list literal type')); |
48 | 37 expect(stdout, contains('2 errors found')); |
49 expect(exitCode, 3); | 38 } |
50 var stdout = outSink.toString(); | |
51 expect(stdout, contains('[error] Invalid override')); | |
52 expect(stdout, contains('[error] Type check failed')); | |
53 expect(stdout, contains('2 errors found.')); | |
54 expect(errorSink.toString(), ''); | |
55 }); | |
56 }); | |
57 } | 39 } |
OLD | NEW |