OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // Test that the '--show-package-warnings' option works as intended. | 5 // Test that the '--show-package-warnings' option works as intended. |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'package:async_helper/async_helper.dart'; | 8 import 'package:async_helper/async_helper.dart'; |
9 import 'package:expect/expect.dart'; | 9 import 'package:expect/expect.dart'; |
| 10 import 'package:compiler/src/commandline_options.dart'; |
10 import 'memory_compiler.dart'; | 11 import 'memory_compiler.dart'; |
11 | 12 |
12 /// Error code that creates 1 warning, 1 hint, and 1 info. | 13 /// Error code that creates 1 warning, 1 hint, and 1 info. |
13 const ERROR_CODE = """ | 14 const ERROR_CODE = """ |
14 m(Object o) { | 15 m(Object o) { |
15 if (o is String) { | 16 if (o is String) { |
16 o = o.length; | 17 o = o.length; |
17 } | 18 } |
18 }"""; | 19 }"""; |
19 | 20 |
(...skipping 20 matching lines...) Expand all Loading... |
40 'pkg/pkg_noerror/pkg_noerror.dart': """ | 41 'pkg/pkg_noerror/pkg_noerror.dart': """ |
41 import 'package:pkg_error1/pkg_error1.dart'; | 42 import 'package:pkg_error1/pkg_error1.dart'; |
42 import 'package:pkg_error2/pkg_error2.dart'; | 43 import 'package:pkg_error2/pkg_error2.dart'; |
43 """}; | 44 """}; |
44 | 45 |
45 Future test(Uri entryPoint, | 46 Future test(Uri entryPoint, |
46 {bool showPackageWarnings: false, | 47 {bool showPackageWarnings: false, |
47 int warnings: 0, | 48 int warnings: 0, |
48 int hints: 0, | 49 int hints: 0, |
49 int infos: 0}) async { | 50 int infos: 0}) async { |
50 var options = ['--analyze-only', '--analyze-all']; | 51 var options = [Flags.analyzeOnly, Flags.analyzeAll]; |
51 if (showPackageWarnings) { | 52 if (showPackageWarnings) { |
52 options.add('--show-package-warnings'); | 53 options.add(Flags.showPackageWarnings); |
53 } | 54 } |
54 var collector = new DiagnosticCollector(); | 55 var collector = new DiagnosticCollector(); |
55 await runCompiler( | 56 await runCompiler( |
56 entryPoint: entryPoint, | 57 entryPoint: entryPoint, |
57 memorySourceFiles: SOURCE, | 58 memorySourceFiles: SOURCE, |
58 options: options, | 59 options: options, |
59 packageRoot: Uri.parse('memory:pkg/'), | 60 packageRoot: Uri.parse('memory:pkg/'), |
60 diagnosticHandler: collector); | 61 diagnosticHandler: collector); |
61 print('=================================================================='); | 62 print('=================================================================='); |
62 print('test: $entryPoint showPackageWarnings=$showPackageWarnings'); | 63 print('test: $entryPoint showPackageWarnings=$showPackageWarnings'); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 showPackageWarnings: true, | 111 showPackageWarnings: true, |
111 // From package:pkg_error1 and package:pkg_error2: | 112 // From package:pkg_error1 and package:pkg_error2: |
112 warnings: 2, hints: 2, infos: 2); | 113 warnings: 2, hints: 2, infos: 2); |
113 await test( | 114 await test( |
114 Uri.parse('package:pkg_noerror/pkg_noerror.dart'), | 115 Uri.parse('package:pkg_noerror/pkg_noerror.dart'), |
115 showPackageWarnings: false, | 116 showPackageWarnings: false, |
116 hints: 2 /* from summary */); | 117 hints: 2 /* from summary */); |
117 }); | 118 }); |
118 } | 119 } |
119 | 120 |
OLD | NEW |