Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: tests/compiler/dart2js/hide_package_warnings_test.dart

Issue 173713002: Add --hide-package-warnings option. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comment Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 // Test that the '--hide-package-warnings' option works as intended.
6
7 import 'package:async_helper/async_helper.dart';
8 import 'package:expect/expect.dart';
9
10 import 'memory_compiler.dart';
11
12 /// Error code that creates 1 warning, 1 hint, and 1 info.
13 const ERROR_CODE = """
14 m(Object o) {
15 if (o is String) {
16 o = o.length;
17 }
18 }""";
19
20 const SOURCE = const {
21 'main.dart': """
22 import 'package:pkg_error1/pkg_error1.dart';
23 import 'package:pkg_error2/pkg_error2.dart';
24 import 'package:pkg_noerror/pkg_noerror.dart';
25 import 'error.dart';
26 """,
27
28 'error.dart': ERROR_CODE,
29
30 'pkg/pkg_error1/pkg_error1.dart': """
31 import 'package:pkg_error2/pkg_error2.dart';
32 import 'package:pkg_noerror/pkg_noerror.dart';
33 $ERROR_CODE""",
34
35 'pkg/pkg_error2/pkg_error2.dart': """
36 import 'package:pkg_error1/pkg_error1.dart';
37 import 'package:pkg_noerror/pkg_noerror.dart';
38 $ERROR_CODE""",
39
40 'pkg/pkg_noerror/pkg_noerror.dart': """
41 import 'package:pkg_error1/pkg_error1.dart';
42 import 'package:pkg_error2/pkg_error2.dart';
43 """};
44
45 void test(List<Uri> entryPoints,
46 {bool hidePackageWarnings: false,
47 int warnings: 0,
48 int hints: 0,
49 int infos: 0}) {
50 var options = ['--analyze-only', '--analyze-all'];
51 if (hidePackageWarnings) {
52 options.add('--hide-package-warnings');
53 }
54 var collector = new DiagnosticCollector();
55 var compiler = compilerFor(SOURCE,
56 options: options,
57 packageRoot: Uri.parse('memory:pkg/'),
58 diagnosticHandler: collector);
59 Uri mainUri = null;
60 if (entryPoints.length == 1) {
61 mainUri = entryPoints[0];
62 } else {
63 compiler.librariesToAnalyzeWhenRun = entryPoints;
64 }
65 asyncTest(() => compiler.run(mainUri).then((_) {
66 print('==================================================================');
67 print('test: $entryPoints hidePackageWarnings=$hidePackageWarnings');
68 Expect.equals(0, collector.errors.length,
69 'Unexpected errors: ${collector.errors}');
70 Expect.equals(warnings, collector.warnings.length,
71 'Unexpected warnings: ${collector.warnings}');
72 Expect.equals(hints, collector.hints.length,
73 'Unexpected hints: ${collector.hints}');
74 Expect.equals(infos, collector.infos.length,
75 'Unexpected infos: ${collector.infos}');
76 print('==================================================================');
77 }));
78 }
79
80 void main() {
81 test([Uri.parse('memory:main.dart')],
82 hidePackageWarnings: false,
83 // From error.dart, package:pkg_error1 and package:pkg_error2:
84 warnings: 3, hints: 3, infos: 3);
85 test([Uri.parse('memory:main.dart')],
86 hidePackageWarnings: true,
87 // From error.dart only:
88 warnings: 1, hints: 1, infos: 1);
89 test([Uri.parse('package:pkg_error1/pkg_error1.dart')],
90 hidePackageWarnings: false,
91 // From package:pkg_error1 and package:pkg_error2:
92 warnings: 2, hints: 2, infos: 2);
93 test([Uri.parse('package:pkg_error1/pkg_error1.dart')],
94 hidePackageWarnings: true,
95 // From package:pkg_error1/pkg_error1.dart only:
96 warnings: 1, hints: 1, infos: 1);
97 test([Uri.parse('package:pkg_noerror/pkg_noerror.dart')],
98 hidePackageWarnings: false,
99 // From package:pkg_error1 and package:pkg_error2:
100 warnings: 2, hints: 2, infos: 2);
101 test([Uri.parse('package:pkg_noerror/pkg_noerror.dart')],
102 hidePackageWarnings: true);
103 }
104
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/dart2js.dart ('k') | tests/compiler/dart2js/in_user_code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698