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

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

Issue 1845563003: Skip checking of IMPORT_EXPERIMENTAL_MIRRORS warning in analyze_test_test. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 4 years, 8 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
« no previous file with comments | « no previous file | tests/compiler/dart2js/analyze_test_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 analyze_helper; 5 library analyze_helper;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 import 'package:compiler/compiler.dart' as api; 9 import 'package:compiler/compiler.dart' as api;
10 import 'package:compiler/compiler_new.dart' as new_api; 10 import 'package:compiler/compiler_new.dart' as new_api;
(...skipping 23 matching lines...) Expand all
34 34
35 class CollectingDiagnosticHandler extends FormattingDiagnosticHandler { 35 class CollectingDiagnosticHandler extends FormattingDiagnosticHandler {
36 bool hasWarnings = false; 36 bool hasWarnings = false;
37 bool hasHint = false; 37 bool hasHint = false;
38 bool hasErrors = false; 38 bool hasErrors = false;
39 bool lastWasWhitelisted = false; 39 bool lastWasWhitelisted = false;
40 bool showWhitelisted = true; 40 bool showWhitelisted = true;
41 41
42 Map<String, Map<dynamic/*String|MessageKind*/, int>> whiteListMap 42 Map<String, Map<dynamic/*String|MessageKind*/, int>> whiteListMap
43 = new Map<String, Map<dynamic/*String|MessageKind*/, int>>(); 43 = new Map<String, Map<dynamic/*String|MessageKind*/, int>>();
44 List<MessageKind> skipList;
44 45
45 CollectingDiagnosticHandler( 46 CollectingDiagnosticHandler(
46 Map<String, List/*<String|MessageKind>*/> whiteList, 47 Map<String, List/*<String|MessageKind>*/> whiteList,
48 this.skipList,
47 SourceFileProvider provider) 49 SourceFileProvider provider)
48 : super(provider) { 50 : super(provider) {
49 whiteList.forEach((String file, List/*<String|MessageKind>*/ messageParts) { 51 whiteList.forEach((String file, List/*<String|MessageKind>*/ messageParts) {
50 var useMap = new Map<dynamic/*String|MessageKind*/, int>(); 52 var useMap = new Map<dynamic/*String|MessageKind*/, int>();
51 for (var messagePart in messageParts) { 53 for (var messagePart in messageParts) {
52 useMap[messagePart] = 0; 54 useMap[messagePart] = 0;
53 } 55 }
54 whiteListMap[file] = useMap; 56 whiteListMap[file] = useMap;
55 }); 57 });
56 } 58 }
(...skipping 25 matching lines...) Expand all
82 print("Whitelisted message '$messagePart' suppressed $useCount " 84 print("Whitelisted message '$messagePart' suppressed $useCount "
83 "time(s) in '$file'."); 85 "time(s) in '$file'.");
84 } 86 }
85 } 87 }
86 } 88 }
87 89
88 bool checkWhiteList(Uri uri, Message message, String text) { 90 bool checkWhiteList(Uri uri, Message message, String text) {
89 if (uri == null) { 91 if (uri == null) {
90 return false; 92 return false;
91 } 93 }
94 if (skipList.contains(message.kind)) {
95 return true;
96 }
92 String path = uri.path; 97 String path = uri.path;
93 for (String file in whiteListMap.keys) { 98 for (String file in whiteListMap.keys) {
94 if (path.contains(file)) { 99 if (path.contains(file)) {
95 for (var messagePart in whiteListMap[file].keys) { 100 for (var messagePart in whiteListMap[file].keys) {
96 bool found = false; 101 bool found = false;
97 if (messagePart is String) { 102 if (messagePart is String) {
98 found = text.contains(messagePart); 103 found = text.contains(messagePart);
99 } else { 104 } else {
100 assert(messagePart is MessageKind); 105 assert(messagePart is MessageKind);
101 found = message.kind == messagePart; 106 found = message.kind == messagePart;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 ALL, 167 ALL,
163 /// Analyze all declarations in the main library. 168 /// Analyze all declarations in the main library.
164 MAIN, 169 MAIN,
165 /// Analyze all declarations in the given URIs one at a time. This mode can 170 /// Analyze all declarations in the given URIs one at a time. This mode can
166 /// handle URIs for parts (i.e. skips these). 171 /// handle URIs for parts (i.e. skips these).
167 URI, 172 URI,
168 /// Analyze all declarations reachable from the entry point. 173 /// Analyze all declarations reachable from the entry point.
169 TREE_SHAKING, 174 TREE_SHAKING,
170 } 175 }
171 176
177 /// Analyzes the file(s) in [uriList] using the provided [mode] and checks that
178 /// no messages (errors, warnings or hints) are emitted.
179 ///
180 /// Messages can be generally allowed using [skipList] or on a per-file basis
181 /// using [whiteList].
172 Future analyze(List<Uri> uriList, 182 Future analyze(List<Uri> uriList,
173 Map<String, List/*<String|MessageKind>*/> whiteList, 183 Map<String, List/*<String|MessageKind>*/> whiteList,
174 {AnalysisMode mode: AnalysisMode.ALL, 184 {AnalysisMode mode: AnalysisMode.ALL,
175 CheckResults checkResults, 185 CheckResults checkResults,
176 List<String> options: const <String>[]}) async { 186 List<String> options: const <String>[],
187 List<MessageKind> skipList: const <MessageKind>[]}) async {
177 String testFileName = 188 String testFileName =
178 relativize(Uri.base, Platform.script, Platform.isWindows); 189 relativize(Uri.base, Platform.script, Platform.isWindows);
179 190
180 print(""" 191 print("""
181 192
182 193
183 === 194 ===
184 === NOTE: If this test fails, update [WHITE_LIST] in $testFileName 195 === NOTE: If this test fails, update [WHITE_LIST] in $testFileName
185 === 196 ===
186 197
187 198
188 """); 199 """);
189 200
190 var libraryRoot = currentDirectory.resolve('sdk/'); 201 var libraryRoot = currentDirectory.resolve('sdk/');
191 var packageRoot = 202 var packageRoot =
192 currentDirectory.resolve(Platform.packageRoot); 203 currentDirectory.resolve(Platform.packageRoot);
193 var provider = new CompilerSourceFileProvider(); 204 var provider = new CompilerSourceFileProvider();
194 var handler = new CollectingDiagnosticHandler(whiteList, provider); 205 var handler = new CollectingDiagnosticHandler(whiteList, skipList, provider);
195 options = <String>[Flags.analyzeOnly, '--categories=Client,Server', 206 options = <String>[Flags.analyzeOnly, '--categories=Client,Server',
196 Flags.showPackageWarnings]..addAll(options); 207 Flags.showPackageWarnings]..addAll(options);
197 switch (mode) { 208 switch (mode) {
198 case AnalysisMode.URI: 209 case AnalysisMode.URI:
199 case AnalysisMode.MAIN: 210 case AnalysisMode.MAIN:
200 options.add(Flags.analyzeMain); 211 options.add(Flags.analyzeMain);
201 break; 212 break;
202 case AnalysisMode.ALL: 213 case AnalysisMode.ALL:
203 options.add(Flags.analyzeAll); 214 options.add(Flags.analyzeAll);
204 break; 215 break;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 if (checkResults != null) { 259 if (checkResults != null) {
249 result = checkResults(compiler, handler); 260 result = checkResults(compiler, handler);
250 } else { 261 } else {
251 result = handler.checkResults(); 262 result = handler.checkResults();
252 } 263 }
253 if (!result) { 264 if (!result) {
254 print(MESSAGE); 265 print(MESSAGE);
255 exit(1); 266 exit(1);
256 } 267 }
257 } 268 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/analyze_test_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698