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