| 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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 other is SeleniumTestCommand && | 332 other is SeleniumTestCommand && |
| 333 super._equal(other) && | 333 super._equal(other) && |
| 334 browser == other.browser && | 334 browser == other.browser && |
| 335 url == other.url; | 335 url == other.url; |
| 336 } | 336 } |
| 337 } | 337 } |
| 338 | 338 |
| 339 class AnalysisCommand extends Command { | 339 class AnalysisCommand extends Command { |
| 340 final String flavor; | 340 final String flavor; |
| 341 | 341 |
| 342 // If [fileFilter] is given, only errors/warnings reported by the analyzer |
| 343 // for which [fileFilter] returns [:true:] are considered. |
| 344 final Function fileFilter; |
| 345 |
| 342 AnalysisCommand._(this.flavor, | 346 AnalysisCommand._(this.flavor, |
| 343 String displayName, | 347 String displayName, |
| 344 String executable, | 348 String executable, |
| 345 List<String> arguments, | 349 List<String> arguments, |
| 346 String configurationDir) | 350 String configurationDir, |
| 351 this.fileFilter) |
| 347 : super._(displayName, executable, arguments, configurationDir); | 352 : super._(displayName, executable, arguments, configurationDir); |
| 348 | 353 |
| 349 void _buildHashCode(HashCodeBuilder builder) { | 354 void _buildHashCode(HashCodeBuilder builder) { |
| 350 super._buildHashCode(builder); | 355 super._buildHashCode(builder); |
| 351 builder.add(flavor); | 356 builder.add(flavor); |
| 357 builder.add(fileFilter); |
| 352 } | 358 } |
| 353 | 359 |
| 354 bool _equal(Command other) { | 360 bool _equal(Command other) { |
| 355 return | 361 return |
| 356 other is AnalysisCommand && | 362 other is AnalysisCommand && |
| 357 super._equal(other) && | 363 super._equal(other) && |
| 358 flavor == other.flavor; | 364 flavor == other.flavor && |
| 365 fileFilter == other.fileFilter; |
| 359 } | 366 } |
| 360 } | 367 } |
| 361 | 368 |
| 362 class VmCommand extends Command { | 369 class VmCommand extends Command { |
| 363 VmCommand._(String executable, | 370 VmCommand._(String executable, |
| 364 List<String> arguments, | 371 List<String> arguments, |
| 365 String configurationDir) | 372 String configurationDir) |
| 366 : super._("vm", executable, arguments, configurationDir); | 373 : super._("vm", executable, arguments, configurationDir); |
| 367 } | 374 } |
| 368 | 375 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 String configurationDir) { | 434 String configurationDir) { |
| 428 var command = | 435 var command = |
| 429 new CompilationCommand._(displayName, outputFile, neverSkipCompilation, | 436 new CompilationCommand._(displayName, outputFile, neverSkipCompilation, |
| 430 bootstrapDependencies, executable, arguments, | 437 bootstrapDependencies, executable, arguments, |
| 431 configurationDir); | 438 configurationDir); |
| 432 return _getUniqueCommand(command); | 439 return _getUniqueCommand(command); |
| 433 } | 440 } |
| 434 | 441 |
| 435 AnalysisCommand getAnalysisCommand( | 442 AnalysisCommand getAnalysisCommand( |
| 436 String displayName, executable, arguments, String configurationDir, | 443 String displayName, executable, arguments, String configurationDir, |
| 437 {String flavor: 'dartanalyzer'}) { | 444 {String flavor: 'dartanalyzer', Function fileFilter: null}) { |
| 438 var command = new AnalysisCommand._( | 445 var command = new AnalysisCommand._( |
| 439 flavor, displayName, executable, arguments, configurationDir); | 446 flavor, displayName, executable, arguments, configurationDir, |
| 447 fileFilter); |
| 440 return _getUniqueCommand(command); | 448 return _getUniqueCommand(command); |
| 441 } | 449 } |
| 442 | 450 |
| 443 VmCommand getVmCommand(String executable, | 451 VmCommand getVmCommand(String executable, |
| 444 List<String> arguments, | 452 List<String> arguments, |
| 445 String configurationDir) { | 453 String configurationDir) { |
| 446 var command = new VmCommand._(executable, arguments, configurationDir); | 454 var command = new VmCommand._(executable, arguments, configurationDir); |
| 447 return _getUniqueCommand(command); | 455 return _getUniqueCommand(command); |
| 448 } | 456 } |
| 449 | 457 |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 return !output.contains("PASS"); | 918 return !output.contains("PASS"); |
| 911 } | 919 } |
| 912 } | 920 } |
| 913 | 921 |
| 914 | 922 |
| 915 class AnalysisCommandOutputImpl extends CommandOutputImpl { | 923 class AnalysisCommandOutputImpl extends CommandOutputImpl { |
| 916 // An error line has 8 fields that look like: | 924 // An error line has 8 fields that look like: |
| 917 // ERROR|COMPILER|MISSING_SOURCE|file:/tmp/t.dart|15|1|24|Missing source. | 925 // ERROR|COMPILER|MISSING_SOURCE|file:/tmp/t.dart|15|1|24|Missing source. |
| 918 final int ERROR_LEVEL = 0; | 926 final int ERROR_LEVEL = 0; |
| 919 final int ERROR_TYPE = 1; | 927 final int ERROR_TYPE = 1; |
| 928 final int FILENAME = 3; |
| 920 final int FORMATTED_ERROR = 7; | 929 final int FORMATTED_ERROR = 7; |
| 921 | 930 |
| 922 AnalysisCommandOutputImpl(command, | 931 AnalysisCommandOutputImpl(command, |
| 923 exitCode, | 932 exitCode, |
| 924 timedOut, | 933 timedOut, |
| 925 stdout, | 934 stdout, |
| 926 stderr, | 935 stderr, |
| 927 time, | 936 time, |
| 928 compilationSkipped) : | 937 compilationSkipped) : |
| 929 super(command, | 938 super(command, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 return Expectation.STATIC_WARNING; | 979 return Expectation.STATIC_WARNING; |
| 971 } | 980 } |
| 972 | 981 |
| 973 assert (errors.length == 0 && warnings.length == 0); | 982 assert (errors.length == 0 && warnings.length == 0); |
| 974 assert (!testCase.info.hasCompileError && | 983 assert (!testCase.info.hasCompileError && |
| 975 !testCase.info.hasStaticWarning); | 984 !testCase.info.hasStaticWarning); |
| 976 return Expectation.PASS; | 985 return Expectation.PASS; |
| 977 } | 986 } |
| 978 | 987 |
| 979 void parseAnalyzerOutput(List<String> outErrors, List<String> outWarnings) { | 988 void parseAnalyzerOutput(List<String> outErrors, List<String> outWarnings) { |
| 989 AnalysisCommand analysisCommand = command; |
| 990 Function fileFilter = analysisCommand.fileFilter; |
| 991 if (fileFilter == null) { |
| 992 // If no filter function was given, we don't filter the output at all. |
| 993 fileFilter = (arg) => true; |
| 994 } |
| 995 |
| 980 // Parse a line delimited by the | character using \ as an escape charager | 996 // Parse a line delimited by the | character using \ as an escape charager |
| 981 // like: FOO|BAR|FOO\|BAR|FOO\\BAZ as 4 fields: FOO BAR FOO|BAR FOO\BAZ | 997 // like: FOO|BAR|FOO\|BAR|FOO\\BAZ as 4 fields: FOO BAR FOO|BAR FOO\BAZ |
| 982 List<String> splitMachineError(String line) { | 998 List<String> splitMachineError(String line) { |
| 983 StringBuffer field = new StringBuffer(); | 999 StringBuffer field = new StringBuffer(); |
| 984 List<String> result = []; | 1000 List<String> result = []; |
| 985 bool escaped = false; | 1001 bool escaped = false; |
| 986 for (var i = 0 ; i < line.length; i++) { | 1002 for (var i = 0 ; i < line.length; i++) { |
| 987 var c = line[i]; | 1003 var c = line[i]; |
| 988 if (!escaped && c == '\\') { | 1004 if (!escaped && c == '\\') { |
| 989 escaped = true; | 1005 escaped = true; |
| 990 continue; | 1006 continue; |
| 991 } | 1007 } |
| 992 escaped = false; | 1008 escaped = false; |
| 993 if (c == '|') { | 1009 if (c == '|') { |
| 994 result.add(field.toString()); | 1010 result.add(field.toString()); |
| 995 field = new StringBuffer(); | 1011 field = new StringBuffer(); |
| 996 continue; | 1012 continue; |
| 997 } | 1013 } |
| 998 field.write(c); | 1014 field.write(c); |
| 999 } | 1015 } |
| 1000 result.add(field.toString()); | 1016 result.add(field.toString()); |
| 1001 return result; | 1017 return result; |
| 1002 } | 1018 } |
| 1003 | 1019 |
| 1004 for (String line in decodeUtf8(super.stderr).split("\n")) { | 1020 for (String line in decodeUtf8(super.stderr).split("\n")) { |
| 1005 if (line.length == 0) continue; | 1021 if (line.length == 0) continue; |
| 1006 List<String> fields = splitMachineError(line); | 1022 List<String> fields = splitMachineError(line); |
| 1007 if (fields[ERROR_LEVEL] == 'ERROR') { | 1023 // We only consider errors/warnings for files of interest. |
| 1008 outErrors.add(fields[FORMATTED_ERROR]); | 1024 if (fields.length > FILENAME) { |
| 1009 } else if (fields[ERROR_LEVEL] == 'WARNING') { | 1025 if (fileFilter(fields[FILENAME])) { |
| 1010 outWarnings.add(fields[FORMATTED_ERROR]); | 1026 if (fields[ERROR_LEVEL] == 'ERROR') { |
| 1027 outErrors.add(fields[FORMATTED_ERROR]); |
| 1028 } else if (fields[ERROR_LEVEL] == 'WARNING') { |
| 1029 outWarnings.add(fields[FORMATTED_ERROR]); |
| 1030 } |
| 1031 } |
| 1032 // OK to Skip error output that doesn't match the machine format |
| 1011 } | 1033 } |
| 1012 // OK to Skip error output that doesn't match the machine format | |
| 1013 } | 1034 } |
| 1014 } | 1035 } |
| 1015 } | 1036 } |
| 1016 | 1037 |
| 1017 class VmCommandOutputImpl extends CommandOutputImpl | 1038 class VmCommandOutputImpl extends CommandOutputImpl |
| 1018 with UnittestSuiteMessagesMixin { | 1039 with UnittestSuiteMessagesMixin { |
| 1019 static const DART_VM_EXITCODE_COMPILE_TIME_ERROR = 254; | 1040 static const DART_VM_EXITCODE_COMPILE_TIME_ERROR = 254; |
| 1020 static const DART_VM_EXITCODE_UNCAUGHT_EXCEPTION = 255; | 1041 static const DART_VM_EXITCODE_UNCAUGHT_EXCEPTION = 255; |
| 1021 | 1042 |
| 1022 VmCommandOutputImpl(Command command, int exitCode, bool timedOut, | 1043 VmCommandOutputImpl(Command command, int exitCode, bool timedOut, |
| (...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2288 } | 2309 } |
| 2289 } | 2310 } |
| 2290 | 2311 |
| 2291 void eventAllTestsDone() { | 2312 void eventAllTestsDone() { |
| 2292 for (var listener in _eventListener) { | 2313 for (var listener in _eventListener) { |
| 2293 listener.allDone(); | 2314 listener.allDone(); |
| 2294 } | 2315 } |
| 2295 _allDone(); | 2316 _allDone(); |
| 2296 } | 2317 } |
| 2297 } | 2318 } |
| OLD | NEW |