| OLD | NEW |
| 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 '../../../sdk/lib/_internal/compiler/compiler.dart' as api; | 9 import '../../../sdk/lib/_internal/compiler/compiler.dart' as api; |
| 10 import '../../../sdk/lib/_internal/compiler/implementation/apiimpl.dart'; | 10 import '../../../sdk/lib/_internal/compiler/implementation/apiimpl.dart'; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 bool checkWhiteList(Uri uri, String message) { | 80 bool checkWhiteList(Uri uri, String message) { |
| 81 if (uri == null) { | 81 if (uri == null) { |
| 82 return false; | 82 return false; |
| 83 } | 83 } |
| 84 String path = uri.path; | 84 String path = uri.path; |
| 85 for (String file in whiteListMap.keys) { | 85 for (String file in whiteListMap.keys) { |
| 86 if (path.endsWith(file)) { | 86 if (path.contains(file)) { |
| 87 for (String messagePart in whiteListMap[file].keys) { | 87 for (String messagePart in whiteListMap[file].keys) { |
| 88 if (message.contains(messagePart)) { | 88 if (message.contains(messagePart)) { |
| 89 whiteListMap[file][messagePart]++; | 89 whiteListMap[file][messagePart]++; |
| 90 return true; | 90 return true; |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 return false; | 95 return false; |
| 96 } | 96 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 122 hasErrors = true; | 122 hasErrors = true; |
| 123 } | 123 } |
| 124 if (kind == api.Diagnostic.INFO && lastWasWhitelisted) { | 124 if (kind == api.Diagnostic.INFO && lastWasWhitelisted) { |
| 125 return; | 125 return; |
| 126 } | 126 } |
| 127 lastWasWhitelisted = false; | 127 lastWasWhitelisted = false; |
| 128 super.diagnosticHandler(uri, begin, end, message, kind); | 128 super.diagnosticHandler(uri, begin, end, message, kind); |
| 129 } | 129 } |
| 130 } | 130 } |
| 131 | 131 |
| 132 typedef bool CheckResults(Compiler compiler, |
| 133 CollectingDiagnosticHandler handler); |
| 134 |
| 132 Future analyze(List<Uri> uriList, | 135 Future analyze(List<Uri> uriList, |
| 133 Map<String, List<String>> whiteList, | 136 Map<String, List<String>> whiteList, |
| 134 {bool analyzeAll: true}) { | 137 {bool analyzeAll: true, |
| 138 CheckResults checkResults}) { |
| 135 String testFileName = | 139 String testFileName = |
| 136 relativize(Uri.base, Platform.script, Platform.isWindows); | 140 relativize(Uri.base, Platform.script, Platform.isWindows); |
| 137 | 141 |
| 138 print(""" | 142 print(""" |
| 139 | 143 |
| 140 | 144 |
| 141 === | 145 === |
| 142 === NOTE: If this test fails, update [WHITE_LIST] in $testFileName | 146 === NOTE: If this test fails, update [WHITE_LIST] in $testFileName |
| 143 === | 147 === |
| 144 | 148 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 161 | 165 |
| 162 | 166 |
| 163 === | 167 === |
| 164 === ERROR: Unexpected result of analysis. | 168 === ERROR: Unexpected result of analysis. |
| 165 === | 169 === |
| 166 === Please update [WHITE_LIST] in $testFileName | 170 === Please update [WHITE_LIST] in $testFileName |
| 167 === | 171 === |
| 168 """; | 172 """; |
| 169 | 173 |
| 170 void onCompletion(_) { | 174 void onCompletion(_) { |
| 171 bool result = handler.checkResults(); | 175 bool result; |
| 176 if (checkResults != null) { |
| 177 result = checkResults(compiler, handler); |
| 178 } else { |
| 179 result = handler.checkResults(); |
| 180 } |
| 172 if (!result) { | 181 if (!result) { |
| 173 print(MESSAGE); | 182 print(MESSAGE); |
| 174 exit(1); | 183 exit(1); |
| 175 } | 184 } |
| 176 } | 185 } |
| 177 if (analyzeAll) { | 186 if (analyzeAll) { |
| 178 compiler.librariesToAnalyzeWhenRun = uriList; | 187 compiler.librariesToAnalyzeWhenRun = uriList; |
| 179 return compiler.run(null).then(onCompletion); | 188 return compiler.run(null).then(onCompletion); |
| 180 } else { | 189 } else { |
| 181 return compiler.run(uriList.single).then(onCompletion); | 190 return compiler.run(uriList.single).then(onCompletion); |
| 182 } | 191 } |
| 183 } | 192 } |
| OLD | NEW |