| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** | 5 /** |
| 6 * Classes and methods for executing tests. | 6 * Classes and methods for executing tests. |
| 7 * | 7 * |
| 8 * This module includes: | 8 * This module includes: |
| 9 * - Managing parallel execution of tests, including timeout checks. | 9 * - Managing parallel execution of tests, including timeout checks. |
| 10 * - Evaluating the output of each test as pass/fail/crash/timeout. | 10 * - Evaluating the output of each test as pass/fail/crash/timeout. |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 super._equal(other) && | 305 super._equal(other) && |
| 306 browser == other.browser && | 306 browser == other.browser && |
| 307 url == other.url && | 307 url == other.url && |
| 308 checkedMode == other.checkedMode; | 308 checkedMode == other.checkedMode; |
| 309 } | 309 } |
| 310 } | 310 } |
| 311 | 311 |
| 312 class AnalysisCommand extends Command { | 312 class AnalysisCommand extends Command { |
| 313 final String flavor; | 313 final String flavor; |
| 314 | 314 |
| 315 // If [fileFilter] is given, only errors/warnings reported by the analyzer | |
| 316 // for which [fileFilter] returns [:true:] are considered. | |
| 317 final Function fileFilter; | |
| 318 | |
| 319 AnalysisCommand._(this.flavor, | 315 AnalysisCommand._(this.flavor, |
| 320 String displayName, | 316 String displayName, |
| 321 String executable, | 317 String executable, |
| 322 List<String> arguments, | 318 List<String> arguments, |
| 323 String configurationDir, | 319 String configurationDir) |
| 324 this.fileFilter) | |
| 325 : super._(displayName, executable, arguments, configurationDir); | 320 : super._(displayName, executable, arguments, configurationDir); |
| 326 | 321 |
| 327 void _buildHashCode(HashCodeBuilder builder) { | 322 void _buildHashCode(HashCodeBuilder builder) { |
| 328 super._buildHashCode(builder); | 323 super._buildHashCode(builder); |
| 329 builder.add(flavor); | 324 builder.add(flavor); |
| 330 builder.add(fileFilter); | |
| 331 } | 325 } |
| 332 | 326 |
| 333 bool _equal(Command other) { | 327 bool _equal(Command other) { |
| 334 return | 328 return |
| 335 other is AnalysisCommand && | 329 other is AnalysisCommand && |
| 336 super._equal(other) && | 330 super._equal(other) && |
| 337 flavor == other.flavor && | 331 flavor == other.flavor; |
| 338 fileFilter == other.fileFilter; | |
| 339 } | 332 } |
| 340 } | 333 } |
| 341 | 334 |
| 342 class VmCommand extends Command { | 335 class VmCommand extends Command { |
| 343 VmCommand._(String executable, | 336 VmCommand._(String executable, |
| 344 List<String> arguments, | 337 List<String> arguments, |
| 345 String configurationDir) | 338 String configurationDir) |
| 346 : super._("vm", executable, arguments, configurationDir); | 339 : super._("vm", executable, arguments, configurationDir); |
| 347 } | 340 } |
| 348 | 341 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 String configurationDir) { | 390 String configurationDir) { |
| 398 var command = | 391 var command = |
| 399 new CompilationCommand._(displayName, outputFile, neverSkipCompilation, | 392 new CompilationCommand._(displayName, outputFile, neverSkipCompilation, |
| 400 bootstrapDependencies, executable, arguments, | 393 bootstrapDependencies, executable, arguments, |
| 401 configurationDir); | 394 configurationDir); |
| 402 return _getUniqueCommand(command); | 395 return _getUniqueCommand(command); |
| 403 } | 396 } |
| 404 | 397 |
| 405 AnalysisCommand getAnalysisCommand( | 398 AnalysisCommand getAnalysisCommand( |
| 406 String displayName, executable, arguments, String configurationDir, | 399 String displayName, executable, arguments, String configurationDir, |
| 407 {String flavor: 'dartanalyzer', Function fileFilter: null}) { | 400 {String flavor: 'dartanalyzer'}) { |
| 408 var command = new AnalysisCommand._( | 401 var command = new AnalysisCommand._( |
| 409 flavor, displayName, executable, arguments, configurationDir, | 402 flavor, displayName, executable, arguments, configurationDir); |
| 410 fileFilter); | |
| 411 return _getUniqueCommand(command); | 403 return _getUniqueCommand(command); |
| 412 } | 404 } |
| 413 | 405 |
| 414 VmCommand getVmCommand(String executable, | 406 VmCommand getVmCommand(String executable, |
| 415 List<String> arguments, | 407 List<String> arguments, |
| 416 String configurationDir) { | 408 String configurationDir) { |
| 417 var command = new VmCommand._(executable, arguments, configurationDir); | 409 var command = new VmCommand._(executable, arguments, configurationDir); |
| 418 return _getUniqueCommand(command); | 410 return _getUniqueCommand(command); |
| 419 } | 411 } |
| 420 | 412 |
| (...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 } | 1145 } |
| 1154 | 1146 |
| 1155 assert (errors.length == 0 && warnings.length == 0); | 1147 assert (errors.length == 0 && warnings.length == 0); |
| 1156 assert (!testCase.info.hasCompileError && | 1148 assert (!testCase.info.hasCompileError && |
| 1157 !testCase.info.hasStaticWarning); | 1149 !testCase.info.hasStaticWarning); |
| 1158 return Expectation.PASS; | 1150 return Expectation.PASS; |
| 1159 } | 1151 } |
| 1160 | 1152 |
| 1161 void parseAnalyzerOutput(List<String> outErrors, List<String> outWarnings) { | 1153 void parseAnalyzerOutput(List<String> outErrors, List<String> outWarnings) { |
| 1162 AnalysisCommand analysisCommand = command; | 1154 AnalysisCommand analysisCommand = command; |
| 1163 Function fileFilter = analysisCommand.fileFilter; | |
| 1164 if (fileFilter == null) { | |
| 1165 // If no filter function was given, we don't filter the output at all. | |
| 1166 fileFilter = (arg) => true; | |
| 1167 } | |
| 1168 | 1155 |
| 1169 // Parse a line delimited by the | character using \ as an escape charager | 1156 // Parse a line delimited by the | character using \ as an escape charager |
| 1170 // like: FOO|BAR|FOO\|BAR|FOO\\BAZ as 4 fields: FOO BAR FOO|BAR FOO\BAZ | 1157 // like: FOO|BAR|FOO\|BAR|FOO\\BAZ as 4 fields: FOO BAR FOO|BAR FOO\BAZ |
| 1171 List<String> splitMachineError(String line) { | 1158 List<String> splitMachineError(String line) { |
| 1172 StringBuffer field = new StringBuffer(); | 1159 StringBuffer field = new StringBuffer(); |
| 1173 List<String> result = []; | 1160 List<String> result = []; |
| 1174 bool escaped = false; | 1161 bool escaped = false; |
| 1175 for (var i = 0 ; i < line.length; i++) { | 1162 for (var i = 0 ; i < line.length; i++) { |
| 1176 var c = line[i]; | 1163 var c = line[i]; |
| 1177 if (!escaped && c == '\\') { | 1164 if (!escaped && c == '\\') { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1188 } | 1175 } |
| 1189 result.add(field.toString()); | 1176 result.add(field.toString()); |
| 1190 return result; | 1177 return result; |
| 1191 } | 1178 } |
| 1192 | 1179 |
| 1193 for (String line in decodeUtf8(super.stderr).split("\n")) { | 1180 for (String line in decodeUtf8(super.stderr).split("\n")) { |
| 1194 if (line.length == 0) continue; | 1181 if (line.length == 0) continue; |
| 1195 List<String> fields = splitMachineError(line); | 1182 List<String> fields = splitMachineError(line); |
| 1196 // We only consider errors/warnings for files of interest. | 1183 // We only consider errors/warnings for files of interest. |
| 1197 if (fields.length > FILENAME) { | 1184 if (fields.length > FILENAME) { |
| 1198 if (fileFilter(fields[FILENAME])) { | 1185 if (fields[ERROR_LEVEL] == 'ERROR') { |
| 1199 if (fields[ERROR_LEVEL] == 'ERROR') { | 1186 outErrors.add(fields[FORMATTED_ERROR]); |
| 1200 outErrors.add(fields[FORMATTED_ERROR]); | 1187 } else if (fields[ERROR_LEVEL] == 'WARNING') { |
| 1201 } else if (fields[ERROR_LEVEL] == 'WARNING') { | 1188 outWarnings.add(fields[FORMATTED_ERROR]); |
| 1202 outWarnings.add(fields[FORMATTED_ERROR]); | |
| 1203 } | |
| 1204 } | 1189 } |
| 1205 // OK to Skip error output that doesn't match the machine format | 1190 // OK to Skip error output that doesn't match the machine format |
| 1206 } | 1191 } |
| 1207 } | 1192 } |
| 1208 } | 1193 } |
| 1209 } | 1194 } |
| 1210 | 1195 |
| 1211 class VmCommandOutputImpl extends CommandOutputImpl | 1196 class VmCommandOutputImpl extends CommandOutputImpl |
| 1212 with UnittestSuiteMessagesMixin { | 1197 with UnittestSuiteMessagesMixin { |
| 1213 static const DART_VM_EXITCODE_COMPILE_TIME_ERROR = 254; | 1198 static const DART_VM_EXITCODE_COMPILE_TIME_ERROR = 254; |
| (...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2410 } | 2395 } |
| 2411 } | 2396 } |
| 2412 | 2397 |
| 2413 void eventAllTestsDone() { | 2398 void eventAllTestsDone() { |
| 2414 for (var listener in _eventListener) { | 2399 for (var listener in _eventListener) { |
| 2415 listener.allDone(); | 2400 listener.allDone(); |
| 2416 } | 2401 } |
| 2417 _allDone(); | 2402 _allDone(); |
| 2418 } | 2403 } |
| 2419 } | 2404 } |
| OLD | NEW |