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. |
11 */ | 11 */ |
12 library test_runner; | 12 library test_runner; |
13 | 13 |
14 import "dart:async"; | 14 import "dart:async"; |
15 import "dart:collection" show Queue; | 15 import "dart:collection" show Queue; |
16 import "dart:convert" show LineSplitter, UTF8, JSON; | 16 import "dart:convert" show LineSplitter, UTF8, JSON; |
17 // We need to use the 'io' prefix here, otherwise io.exitCode will shadow | 17 // We need to use the 'io' prefix here, otherwise io.exitCode will shadow |
18 // CommandOutput.exitCode in subclasses of CommandOutput. | 18 // CommandOutput.exitCode in subclasses of CommandOutput. |
19 import "dart:io" as io; | 19 import "dart:io" as io; |
20 import "dart:math" as math; | 20 import "dart:math" as math; |
21 | 21 |
22 import 'android.dart'; | 22 import 'android.dart'; |
23 import "browser_controller.dart"; | 23 import "browser_controller.dart"; |
24 import 'dependency_graph.dart' as dgraph; | 24 import 'dependency_graph.dart' as dgraph; |
| 25 import "expectation.dart"; |
25 import "path.dart"; | 26 import "path.dart"; |
26 import 'record_and_replay.dart'; | 27 import 'record_and_replay.dart'; |
27 import "runtime_configuration.dart"; | 28 import "runtime_configuration.dart"; |
28 import "status_file_parser.dart"; | |
29 import "test_progress.dart"; | 29 import "test_progress.dart"; |
30 import "test_suite.dart"; | 30 import "test_suite.dart"; |
31 import "utils.dart"; | 31 import "utils.dart"; |
32 | 32 |
33 const int CRASHING_BROWSER_EXITCODE = -10; | 33 const int CRASHING_BROWSER_EXITCODE = -10; |
34 const int SLOW_TIMEOUT_MULTIPLIER = 4; | 34 const int SLOW_TIMEOUT_MULTIPLIER = 4; |
35 const int NON_UTF_FAKE_EXITCODE = 0xFFFD; | 35 const int NON_UTF_FAKE_EXITCODE = 0xFFFD; |
36 | 36 |
37 const MESSAGE_CANNOT_OPEN_DISPLAY = 'Gtk-WARNING **: cannot open display'; | 37 const MESSAGE_CANNOT_OPEN_DISPLAY = 'Gtk-WARNING **: cannot open display'; |
38 const MESSAGE_FAILED_TO_RUN_COMMAND = 'Failed to run command. return code=1'; | 38 const MESSAGE_FAILED_TO_RUN_COMMAND = 'Failed to run command. return code=1'; |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 if (exists) { | 489 if (exists) { |
490 cleanDirectoryFuture = TestUtils.deleteDirectory(_destinationDirectory); | 490 cleanDirectoryFuture = TestUtils.deleteDirectory(_destinationDirectory); |
491 } else { | 491 } else { |
492 cleanDirectoryFuture = new Future.value(null); | 492 cleanDirectoryFuture = new Future.value(null); |
493 } | 493 } |
494 return cleanDirectoryFuture.then((_) { | 494 return cleanDirectoryFuture.then((_) { |
495 return TestUtils.copyDirectory(_sourceDirectory, _destinationDirectory); | 495 return TestUtils.copyDirectory(_sourceDirectory, _destinationDirectory); |
496 }); | 496 }); |
497 }).then((_) { | 497 }).then((_) { |
498 return new ScriptCommandOutputImpl( | 498 return new ScriptCommandOutputImpl( |
499 this, Expectation.PASS, "", watch.elapsed); | 499 this, Expectation.pass, "", watch.elapsed); |
500 }).catchError((error) { | 500 }).catchError((error) { |
501 return new ScriptCommandOutputImpl( | 501 return new ScriptCommandOutputImpl( |
502 this, Expectation.FAIL, "An error occured: $error.", watch.elapsed); | 502 this, Expectation.fail, "An error occured: $error.", watch.elapsed); |
503 }); | 503 }); |
504 } | 504 } |
505 | 505 |
506 void _buildHashCode(HashCodeBuilder builder) { | 506 void _buildHashCode(HashCodeBuilder builder) { |
507 super._buildHashCode(builder); | 507 super._buildHashCode(builder); |
508 builder.addJson(_sourceDirectory); | 508 builder.addJson(_sourceDirectory); |
509 builder.addJson(_destinationDirectory); | 509 builder.addJson(_destinationDirectory); |
510 } | 510 } |
511 | 511 |
512 bool _equal(CleanDirectoryCopyCommand other) => | 512 bool _equal(CleanDirectoryCopyCommand other) => |
(...skipping 21 matching lines...) Expand all Loading... |
534 if (!targetExists) { | 534 if (!targetExists) { |
535 throw new Exception("Target '$_target' does not exist"); | 535 throw new Exception("Target '$_target' does not exist"); |
536 } | 536 } |
537 var link = new io.Link(_link); | 537 var link = new io.Link(_link); |
538 | 538 |
539 return link.exists().then((bool exists) { | 539 return link.exists().then((bool exists) { |
540 if (exists) return link.delete(); | 540 if (exists) return link.delete(); |
541 }).then((_) => link.create(_target)); | 541 }).then((_) => link.create(_target)); |
542 }).then((_) { | 542 }).then((_) { |
543 return new ScriptCommandOutputImpl( | 543 return new ScriptCommandOutputImpl( |
544 this, Expectation.PASS, "", watch.elapsed); | 544 this, Expectation.pass, "", watch.elapsed); |
545 }).catchError((error) { | 545 }).catchError((error) { |
546 return new ScriptCommandOutputImpl( | 546 return new ScriptCommandOutputImpl( |
547 this, Expectation.FAIL, "An error occured: $error.", watch.elapsed); | 547 this, Expectation.fail, "An error occured: $error.", watch.elapsed); |
548 }); | 548 }); |
549 } | 549 } |
550 | 550 |
551 void _buildHashCode(HashCodeBuilder builder) { | 551 void _buildHashCode(HashCodeBuilder builder) { |
552 super._buildHashCode(builder); | 552 super._buildHashCode(builder); |
553 builder.addJson(_link); | 553 builder.addJson(_link); |
554 builder.addJson(_target); | 554 builder.addJson(_target); |
555 } | 555 } |
556 | 556 |
557 bool _equal(MakeSymlinkCommand other) => | 557 bool _equal(MakeSymlinkCommand other) => |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 Command get lastCommandExecuted { | 820 Command get lastCommandExecuted { |
821 if (commandOutputs.length == 0) { | 821 if (commandOutputs.length == 0) { |
822 throw new Exception("CommandOutputs is empty, maybe no command was run? (" | 822 throw new Exception("CommandOutputs is empty, maybe no command was run? (" |
823 "displayName: '$displayName', " | 823 "displayName: '$displayName', " |
824 "configurationString: '$configurationString')"); | 824 "configurationString: '$configurationString')"); |
825 } | 825 } |
826 return commands[commandOutputs.length - 1]; | 826 return commands[commandOutputs.length - 1]; |
827 } | 827 } |
828 | 828 |
829 int get timeout { | 829 int get timeout { |
830 if (expectedOutcomes.contains(Expectation.SLOW)) { | 830 if (expectedOutcomes.contains(Expectation.slow)) { |
831 return configuration['timeout'] * SLOW_TIMEOUT_MULTIPLIER; | 831 return configuration['timeout'] * SLOW_TIMEOUT_MULTIPLIER; |
832 } else { | 832 } else { |
833 return configuration['timeout']; | 833 return configuration['timeout']; |
834 } | 834 } |
835 } | 835 } |
836 | 836 |
837 String get configurationString { | 837 String get configurationString { |
838 final compiler = configuration['compiler']; | 838 final compiler = configuration['compiler']; |
839 final runtime = configuration['runtime']; | 839 final runtime = configuration['runtime']; |
840 final mode = configuration['mode']; | 840 final mode = configuration['mode']; |
841 final arch = configuration['arch']; | 841 final arch = configuration['arch']; |
842 final checked = configuration['checked'] ? '-checked' : ''; | 842 final checked = configuration['checked'] ? '-checked' : ''; |
843 return "$compiler-$runtime$checked ${mode}_$arch"; | 843 return "$compiler-$runtime$checked ${mode}_$arch"; |
844 } | 844 } |
845 | 845 |
846 List<String> get batchTestArguments { | 846 List<String> get batchTestArguments { |
847 assert(commands.last is ProcessCommand); | 847 assert(commands.last is ProcessCommand); |
848 return (commands.last as ProcessCommand).arguments; | 848 return (commands.last as ProcessCommand).arguments; |
849 } | 849 } |
850 | 850 |
851 bool get isFlaky { | 851 bool get isFlaky { |
852 if (expectedOutcomes.contains(Expectation.SKIP) || | 852 if (expectedOutcomes.contains(Expectation.skip) || |
853 expectedOutcomes.contains(Expectation.SKIP_BY_DESIGN)) { | 853 expectedOutcomes.contains(Expectation.skipByDesign)) { |
854 return false; | 854 return false; |
855 } | 855 } |
856 | 856 |
857 return expectedOutcomes | 857 return expectedOutcomes |
858 .where((expectation) => !expectation.isMetaExpectation) | 858 .where((expectation) => expectation.isOutcome) |
859 .length > | 859 .length > |
860 1; | 860 1; |
861 } | 861 } |
862 | 862 |
863 bool get isFinished { | 863 bool get isFinished { |
864 return commandOutputs.length > 0 && | 864 return commandOutputs.length > 0 && |
865 (!lastCommandOutput.successful || | 865 (!lastCommandOutput.successful || |
866 commands.length == commandOutputs.length); | 866 commands.length == commandOutputs.length); |
867 } | 867 } |
868 } | 868 } |
(...skipping 27 matching lines...) Expand all Loading... |
896 | 896 |
897 bool _isAsyncTestSuccessful(String testOutput) { | 897 bool _isAsyncTestSuccessful(String testOutput) { |
898 return testOutput.contains("unittest-suite-success"); | 898 return testOutput.contains("unittest-suite-success"); |
899 } | 899 } |
900 | 900 |
901 Expectation _negateOutcomeIfIncompleteAsyncTest( | 901 Expectation _negateOutcomeIfIncompleteAsyncTest( |
902 Expectation outcome, String testOutput) { | 902 Expectation outcome, String testOutput) { |
903 // If this is an asynchronous test and the asynchronous operation didn't | 903 // If this is an asynchronous test and the asynchronous operation didn't |
904 // complete successfully, it's outcome is Expectation.FAIL. | 904 // complete successfully, it's outcome is Expectation.FAIL. |
905 // TODO: maybe we should introduce a AsyncIncomplete marker or so | 905 // TODO: maybe we should introduce a AsyncIncomplete marker or so |
906 if (outcome == Expectation.PASS) { | 906 if (outcome == Expectation.pass) { |
907 if (_isAsyncTest(testOutput) && !_isAsyncTestSuccessful(testOutput)) { | 907 if (_isAsyncTest(testOutput) && !_isAsyncTestSuccessful(testOutput)) { |
908 return Expectation.FAIL; | 908 return Expectation.fail; |
909 } | 909 } |
910 } | 910 } |
911 return outcome; | 911 return outcome; |
912 } | 912 } |
913 } | 913 } |
914 | 914 |
915 /** | 915 /** |
916 * CommandOutput records the output of a completed command: the process's exit | 916 * CommandOutput records the output of a completed command: the process's exit |
917 * code, the standard output and standard error, whether the process timed out, | 917 * code, the standard output and standard error, whether the process timed out, |
918 * and the time the process took to run. It does not contain a pointer to the | 918 * and the time the process took to run. It does not contain a pointer to the |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
975 bool this.timedOut, | 975 bool this.timedOut, |
976 List<int> this.stdout, | 976 List<int> this.stdout, |
977 List<int> this.stderr, | 977 List<int> this.stderr, |
978 Duration this.time, | 978 Duration this.time, |
979 bool this.compilationSkipped, | 979 bool this.compilationSkipped, |
980 int this.pid) { | 980 int this.pid) { |
981 diagnostics = []; | 981 diagnostics = []; |
982 } | 982 } |
983 | 983 |
984 Expectation result(TestCase testCase) { | 984 Expectation result(TestCase testCase) { |
985 if (hasCrashed) return Expectation.CRASH; | 985 if (hasCrashed) return Expectation.crash; |
986 if (hasTimedOut) return Expectation.TIMEOUT; | 986 if (hasTimedOut) return Expectation.timeout; |
987 if (hasFailed(testCase)) return Expectation.FAIL; | 987 if (hasFailed(testCase)) return Expectation.fail; |
988 if (hasNonUtf8) return Expectation.NON_UTF8_ERROR; | 988 if (hasNonUtf8) return Expectation.nonUtf8Error; |
989 return Expectation.PASS; | 989 return Expectation.pass; |
990 } | 990 } |
991 | 991 |
992 bool get hasCrashed { | 992 bool get hasCrashed { |
993 // dart2js exits with code 253 in case of unhandled exceptions. | 993 // dart2js exits with code 253 in case of unhandled exceptions. |
994 // The dart binary exits with code 253 in case of an API error such | 994 // The dart binary exits with code 253 in case of an API error such |
995 // as an invalid snapshot file. | 995 // as an invalid snapshot file. |
996 // In either case an exit code of 253 is considered a crash. | 996 // In either case an exit code of 253 is considered a crash. |
997 if (exitCode == 253) return true; | 997 if (exitCode == 253) return true; |
998 if (io.Platform.operatingSystem == 'windows') { | 998 if (io.Platform.operatingSystem == 'windows') { |
999 // The VM uses std::abort to terminate on asserts. | 999 // The VM uses std::abort to terminate on asserts. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 // Reverse result of a negative test. | 1031 // Reverse result of a negative test. |
1032 bool hasFailed(TestCase testCase) { | 1032 bool hasFailed(TestCase testCase) { |
1033 return testCase.isNegative ? !didFail(testCase) : didFail(testCase); | 1033 return testCase.isNegative ? !didFail(testCase) : didFail(testCase); |
1034 } | 1034 } |
1035 | 1035 |
1036 bool get hasNonUtf8 => exitCode == NON_UTF_FAKE_EXITCODE; | 1036 bool get hasNonUtf8 => exitCode == NON_UTF_FAKE_EXITCODE; |
1037 | 1037 |
1038 Expectation _negateOutcomeIfNegativeTest( | 1038 Expectation _negateOutcomeIfNegativeTest( |
1039 Expectation outcome, bool isNegative) { | 1039 Expectation outcome, bool isNegative) { |
1040 if (!isNegative) return outcome; | 1040 if (!isNegative) return outcome; |
1041 if (outcome == Expectation.IGNORE) return outcome; | 1041 if (outcome == Expectation.ignore) return outcome; |
1042 if (outcome.canBeOutcomeOf(Expectation.FAIL)) { | 1042 if (outcome.canBeOutcomeOf(Expectation.fail)) { |
1043 return Expectation.PASS; | 1043 return Expectation.pass; |
1044 } | 1044 } |
1045 return Expectation.FAIL; | 1045 return Expectation.fail; |
1046 } | 1046 } |
1047 } | 1047 } |
1048 | 1048 |
1049 class BrowserCommandOutputImpl extends CommandOutputImpl { | 1049 class BrowserCommandOutputImpl extends CommandOutputImpl { |
1050 // Although tests are reported as passing, content shell sometimes exits with | 1050 // Although tests are reported as passing, content shell sometimes exits with |
1051 // a nonzero exitcode which makes our dartium builders extremely falky. | 1051 // a nonzero exitcode which makes our dartium builders extremely falky. |
1052 // See: http://dartbug.com/15139. | 1052 // See: http://dartbug.com/15139. |
| 1053 // TODO(rnystrom): Is this still needed? The underlying bug is closed. |
1053 static int WHITELISTED_CONTENTSHELL_EXITCODE = -1073740022; | 1054 static int WHITELISTED_CONTENTSHELL_EXITCODE = -1073740022; |
1054 static bool isWindows = io.Platform.operatingSystem == 'windows'; | 1055 static bool isWindows = io.Platform.operatingSystem == 'windows'; |
1055 static bool _failedBecauseOfFlakyInfrastructure( | 1056 static bool _failedBecauseOfFlakyInfrastructure( |
1056 Command command, bool timedOut, List<int> stderrBytes) { | 1057 Command command, bool timedOut, List<int> stderrBytes) { |
1057 // If the browser test failed, it may have been because content shell | 1058 // If the browser test failed, it may have been because content shell |
1058 // and the virtual framebuffer X server didn't hook up, or it crashed with | 1059 // and the virtual framebuffer X server didn't hook up, or it crashed with |
1059 // a core dump. Sometimes content shell crashes after it has set the stdout | 1060 // a core dump. Sometimes content shell crashes after it has set the stdout |
1060 // to PASS, so we have to do this check first. | 1061 // to PASS, so we have to do this check first. |
1061 // Content shell also fails with a broken pipe message: Issue 26739 | 1062 // Content shell also fails with a broken pipe message: Issue 26739 |
1062 var zygoteCrash = | 1063 var zygoteCrash = |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1096 List<int> stderr, | 1097 List<int> stderr, |
1097 Duration time, | 1098 Duration time, |
1098 bool compilationSkipped) | 1099 bool compilationSkipped) |
1099 : _infraFailure = | 1100 : _infraFailure = |
1100 _failedBecauseOfFlakyInfrastructure(command, timedOut, stderr), | 1101 _failedBecauseOfFlakyInfrastructure(command, timedOut, stderr), |
1101 super(command, exitCode, timedOut, stdout, stderr, time, | 1102 super(command, exitCode, timedOut, stdout, stderr, time, |
1102 compilationSkipped, 0); | 1103 compilationSkipped, 0); |
1103 | 1104 |
1104 Expectation result(TestCase testCase) { | 1105 Expectation result(TestCase testCase) { |
1105 if (_infraFailure) { | 1106 if (_infraFailure) { |
1106 return Expectation.IGNORE; | 1107 return Expectation.ignore; |
1107 } | 1108 } |
| 1109 |
1108 // Handle crashes and timeouts first | 1110 // Handle crashes and timeouts first |
1109 if (hasCrashed) return Expectation.CRASH; | 1111 if (hasCrashed) return Expectation.crash; |
1110 if (hasTimedOut) return Expectation.TIMEOUT; | 1112 if (hasTimedOut) return Expectation.timeout; |
1111 if (hasNonUtf8) return Expectation.NON_UTF8_ERROR; | 1113 if (hasNonUtf8) return Expectation.nonUtf8Error; |
1112 | 1114 |
1113 var outcome = _getOutcome(); | 1115 var outcome = _getOutcome(); |
1114 | 1116 |
1115 if (testCase.hasRuntimeError) { | 1117 if (testCase.hasRuntimeError) { |
1116 if (!outcome.canBeOutcomeOf(Expectation.RUNTIME_ERROR)) { | 1118 if (!outcome.canBeOutcomeOf(Expectation.runtimeError)) { |
1117 return Expectation.MISSING_RUNTIME_ERROR; | 1119 return Expectation.missingRuntimeError; |
1118 } | 1120 } |
1119 } | 1121 } |
1120 if (testCase.isNegative) { | 1122 if (testCase.isNegative) { |
1121 if (outcome.canBeOutcomeOf(Expectation.FAIL)) return Expectation.PASS; | 1123 if (outcome.canBeOutcomeOf(Expectation.fail)) return Expectation.pass; |
1122 return Expectation.FAIL; | 1124 return Expectation.fail; |
1123 } | 1125 } |
1124 return outcome; | 1126 return outcome; |
1125 } | 1127 } |
1126 | 1128 |
1127 bool get successful => canRunDependendCommands; | 1129 bool get successful => canRunDependendCommands; |
1128 | 1130 |
1129 bool get canRunDependendCommands { | 1131 bool get canRunDependendCommands { |
1130 // We cannot rely on the exit code of content_shell as a method to | 1132 // We cannot rely on the exit code of content_shell as a method to |
1131 // determine if we were successful or not. | 1133 // determine if we were successful or not. |
1132 return super.canRunDependendCommands && !didFail(null); | 1134 return super.canRunDependendCommands && !didFail(null); |
1133 } | 1135 } |
1134 | 1136 |
1135 bool get hasCrashed { | 1137 bool get hasCrashed { |
1136 return super.hasCrashed || _rendererCrashed; | 1138 return super.hasCrashed || _rendererCrashed; |
1137 } | 1139 } |
1138 | 1140 |
1139 Expectation _getOutcome() { | 1141 Expectation _getOutcome() { |
1140 if (_browserTestFailure) { | 1142 if (_browserTestFailure) { |
1141 return Expectation.RUNTIME_ERROR; | 1143 return Expectation.runtimeError; |
1142 } | 1144 } |
1143 return Expectation.PASS; | 1145 return Expectation.pass; |
1144 } | 1146 } |
1145 | 1147 |
1146 bool get _rendererCrashed => | 1148 bool get _rendererCrashed => |
1147 decodeUtf8(super.stdout).contains("#CRASHED - rendere"); | 1149 decodeUtf8(super.stdout).contains("#CRASHED - rendere"); |
1148 | 1150 |
1149 bool get _browserTestFailure { | 1151 bool get _browserTestFailure { |
1150 // Browser tests fail unless stdout contains | 1152 // Browser tests fail unless stdout contains |
1151 // 'Content-Type: text/plain' followed by 'PASS'. | 1153 // 'Content-Type: text/plain' followed by 'PASS'. |
1152 bool hasContentType = false; | 1154 bool hasContentType = false; |
1153 var stdoutLines = decodeUtf8(super.stdout).split("\n"); | 1155 var stdoutLines = decodeUtf8(super.stdout).split("\n"); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 int exitCode, | 1208 int exitCode, |
1207 bool timedOut, | 1209 bool timedOut, |
1208 List<int> stdout, | 1210 List<int> stdout, |
1209 List<int> stderr, | 1211 List<int> stderr, |
1210 Duration time, | 1212 Duration time, |
1211 bool compilationSkipped) | 1213 bool compilationSkipped) |
1212 : super(command, exitCode, timedOut, stdout, stderr, time, | 1214 : super(command, exitCode, timedOut, stdout, stderr, time, |
1213 compilationSkipped); | 1215 compilationSkipped); |
1214 | 1216 |
1215 bool didFail(TestCase testCase) { | 1217 bool didFail(TestCase testCase) { |
1216 return _getOutcome() != Expectation.PASS; | 1218 return _getOutcome() != Expectation.pass; |
1217 } | 1219 } |
1218 | 1220 |
1219 bool get _browserTestFailure { | 1221 bool get _browserTestFailure { |
1220 // We should not need to convert back and forward. | 1222 // We should not need to convert back and forward. |
1221 var output = decodeUtf8(super.stdout); | 1223 var output = decodeUtf8(super.stdout); |
1222 if (output.contains("FAIL")) return true; | 1224 if (output.contains("FAIL")) return true; |
1223 return !output.contains("PASS"); | 1225 return !output.contains("PASS"); |
1224 } | 1226 } |
1225 } | 1227 } |
1226 | 1228 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1297 static Expectation _getOutcome(Map<String, List<String>> messagesByType) { | 1299 static Expectation _getOutcome(Map<String, List<String>> messagesByType) { |
1298 occured(String type) => messagesByType[type].length > 0; | 1300 occured(String type) => messagesByType[type].length > 0; |
1299 searchForMsg(List<String> types, String message) { | 1301 searchForMsg(List<String> types, String message) { |
1300 return types.any((type) => messagesByType[type].contains(message)); | 1302 return types.any((type) => messagesByType[type].contains(message)); |
1301 } | 1303 } |
1302 | 1304 |
1303 // FIXME(kustermann,ricow): I think this functionality doesn't work in | 1305 // FIXME(kustermann,ricow): I think this functionality doesn't work in |
1304 // test_controller.js: So far I haven't seen anything being reported on | 1306 // test_controller.js: So far I haven't seen anything being reported on |
1305 // "window.compilationerror" | 1307 // "window.compilationerror" |
1306 if (occured('window_compilationerror')) { | 1308 if (occured('window_compilationerror')) { |
1307 return Expectation.COMPILETIME_ERROR; | 1309 return Expectation.compileTimeError; |
1308 } | 1310 } |
1309 | 1311 |
1310 if (occured('sync_exception') || | 1312 if (occured('sync_exception') || |
1311 occured('window_onerror') || | 1313 occured('window_onerror') || |
1312 occured('script_onerror')) { | 1314 occured('script_onerror')) { |
1313 return Expectation.RUNTIME_ERROR; | 1315 return Expectation.runtimeError; |
1314 } | 1316 } |
1315 | 1317 |
1316 if (messagesByType['dom'][0].contains('FAIL')) { | 1318 if (messagesByType['dom'][0].contains('FAIL')) { |
1317 return Expectation.RUNTIME_ERROR; | 1319 return Expectation.runtimeError; |
1318 } | 1320 } |
1319 | 1321 |
1320 // We search for these messages in 'print' and 'message_received' because | 1322 // We search for these messages in 'print' and 'message_received' because |
1321 // the unittest implementation posts these messages using | 1323 // the unittest implementation posts these messages using |
1322 // "window.postMessage()" instead of the normal "print()" them. | 1324 // "window.postMessage()" instead of the normal "print()" them. |
1323 | 1325 |
1324 var isAsyncTest = searchForMsg( | 1326 var isAsyncTest = searchForMsg( |
1325 ['print', 'message_received'], 'unittest-suite-wait-for-done'); | 1327 ['print', 'message_received'], 'unittest-suite-wait-for-done'); |
1326 var isAsyncSuccess = | 1328 var isAsyncSuccess = |
1327 searchForMsg(['print', 'message_received'], 'unittest-suite-success') || | 1329 searchForMsg(['print', 'message_received'], 'unittest-suite-success') || |
1328 searchForMsg(['print', 'message_received'], 'unittest-suite-done'); | 1330 searchForMsg(['print', 'message_received'], 'unittest-suite-done'); |
1329 | 1331 |
1330 if (isAsyncTest) { | 1332 if (isAsyncTest) { |
1331 if (isAsyncSuccess) { | 1333 if (isAsyncSuccess) { |
1332 return Expectation.PASS; | 1334 return Expectation.pass; |
1333 } | 1335 } |
1334 return Expectation.RUNTIME_ERROR; | 1336 return Expectation.runtimeError; |
1335 } | 1337 } |
1336 | 1338 |
1337 var mainStarted = | 1339 var mainStarted = |
1338 searchForMsg(['print', 'message_received'], 'dart-calling-main'); | 1340 searchForMsg(['print', 'message_received'], 'dart-calling-main'); |
1339 var mainDone = | 1341 var mainDone = |
1340 searchForMsg(['print', 'message_received'], 'dart-main-done'); | 1342 searchForMsg(['print', 'message_received'], 'dart-main-done'); |
1341 | 1343 |
1342 if (mainStarted && mainDone) { | 1344 if (mainStarted && mainDone) { |
1343 return Expectation.PASS; | 1345 return Expectation.pass; |
1344 } | 1346 } |
1345 return Expectation.FAIL; | 1347 return Expectation.fail; |
1346 } | 1348 } |
1347 } | 1349 } |
1348 | 1350 |
1349 class BrowserControllerTestOutcome extends CommandOutputImpl | 1351 class BrowserControllerTestOutcome extends CommandOutputImpl |
1350 with UnittestSuiteMessagesMixin { | 1352 with UnittestSuiteMessagesMixin { |
1351 BrowserTestOutput _result; | 1353 BrowserTestOutput _result; |
1352 Expectation _rawOutcome; | 1354 Expectation _rawOutcome; |
1353 | 1355 |
1354 factory BrowserControllerTestOutcome( | 1356 factory BrowserControllerTestOutcome( |
1355 Command command, BrowserTestOutput result) { | 1357 Command command, BrowserTestOutput result) { |
(...skipping 10 matching lines...) Expand all Loading... |
1366 String stderr = ""; | 1368 String stderr = ""; |
1367 Expectation outcome; | 1369 Expectation outcome; |
1368 | 1370 |
1369 var parsedResult = | 1371 var parsedResult = |
1370 BrowserTestJsonResult.parseFromString(result.lastKnownMessage); | 1372 BrowserTestJsonResult.parseFromString(result.lastKnownMessage); |
1371 if (parsedResult != null) { | 1373 if (parsedResult != null) { |
1372 outcome = parsedResult.outcome; | 1374 outcome = parsedResult.outcome; |
1373 } else { | 1375 } else { |
1374 // Old way of determining whether a test failed or passed. | 1376 // Old way of determining whether a test failed or passed. |
1375 if (result.lastKnownMessage.contains("FAIL")) { | 1377 if (result.lastKnownMessage.contains("FAIL")) { |
1376 outcome = Expectation.RUNTIME_ERROR; | 1378 outcome = Expectation.runtimeError; |
1377 } else if (result.lastKnownMessage.contains("PASS")) { | 1379 } else if (result.lastKnownMessage.contains("PASS")) { |
1378 outcome = Expectation.PASS; | 1380 outcome = Expectation.pass; |
1379 } else { | 1381 } else { |
1380 outcome = Expectation.RUNTIME_ERROR; | 1382 outcome = Expectation.runtimeError; |
1381 } | 1383 } |
1382 } | 1384 } |
1383 | 1385 |
1384 if (result.didTimeout) { | 1386 if (result.didTimeout) { |
1385 if (result.delayUntilTestStarted != null) { | 1387 if (result.delayUntilTestStarted != null) { |
1386 stderr = "This test timed out. The delay until the test actually " | 1388 stderr = "This test timed out. The delay until the test actually " |
1387 "started was: ${result.delayUntilTestStarted}."; | 1389 "started was: ${result.delayUntilTestStarted}."; |
1388 } else { | 1390 } else { |
1389 stderr = "This test has not notified test.py that it started running."; | 1391 stderr = "This test has not notified test.py that it started running."; |
1390 } | 1392 } |
(...skipping 22 matching lines...) Expand all Loading... |
1413 this._rawOutcome, | 1415 this._rawOutcome, |
1414 List<int> stdout, | 1416 List<int> stdout, |
1415 List<int> stderr) | 1417 List<int> stderr) |
1416 : super(command, 0, result.didTimeout, stdout, stderr, result.duration, | 1418 : super(command, 0, result.didTimeout, stdout, stderr, result.duration, |
1417 false, 0) { | 1419 false, 0) { |
1418 _result = result; | 1420 _result = result; |
1419 } | 1421 } |
1420 | 1422 |
1421 Expectation result(TestCase testCase) { | 1423 Expectation result(TestCase testCase) { |
1422 // Handle timeouts first | 1424 // Handle timeouts first |
1423 if (_result.didTimeout) return Expectation.TIMEOUT; | 1425 if (_result.didTimeout) return Expectation.timeout; |
1424 if (hasNonUtf8) return Expectation.NON_UTF8_ERROR; | 1426 if (hasNonUtf8) return Expectation.nonUtf8Error; |
1425 | 1427 |
1426 // Multitests are handled specially | 1428 // Multitests are handled specially |
1427 if (testCase.hasRuntimeError) { | 1429 if (testCase.hasRuntimeError) { |
1428 if (_rawOutcome == Expectation.RUNTIME_ERROR) return Expectation.PASS; | 1430 if (_rawOutcome == Expectation.runtimeError) return Expectation.pass; |
1429 return Expectation.MISSING_RUNTIME_ERROR; | 1431 return Expectation.missingRuntimeError; |
1430 } | 1432 } |
1431 | 1433 |
1432 return _negateOutcomeIfNegativeTest(_rawOutcome, testCase.isNegative); | 1434 return _negateOutcomeIfNegativeTest(_rawOutcome, testCase.isNegative); |
1433 } | 1435 } |
1434 } | 1436 } |
1435 | 1437 |
1436 class AnalysisCommandOutputImpl extends CommandOutputImpl { | 1438 class AnalysisCommandOutputImpl extends CommandOutputImpl { |
1437 // An error line has 8 fields that look like: | 1439 // An error line has 8 fields that look like: |
1438 // ERROR|COMPILER|MISSING_SOURCE|file:/tmp/t.dart|15|1|24|Missing source. | 1440 // ERROR|COMPILER|MISSING_SOURCE|file:/tmp/t.dart|15|1|24|Missing source. |
1439 final int ERROR_LEVEL = 0; | 1441 final int ERROR_LEVEL = 0; |
(...skipping 11 matching lines...) Expand all Loading... |
1451 bool compilationSkipped) | 1453 bool compilationSkipped) |
1452 : super(command, exitCode, timedOut, stdout, stderr, time, | 1454 : super(command, exitCode, timedOut, stdout, stderr, time, |
1453 compilationSkipped, 0); | 1455 compilationSkipped, 0); |
1454 | 1456 |
1455 Expectation result(TestCase testCase) { | 1457 Expectation result(TestCase testCase) { |
1456 // TODO(kustermann): If we run the analyzer not in batch mode, make sure | 1458 // TODO(kustermann): If we run the analyzer not in batch mode, make sure |
1457 // that command.exitCodes matches 2 (errors), 1 (warnings), 0 (no warnings, | 1459 // that command.exitCodes matches 2 (errors), 1 (warnings), 0 (no warnings, |
1458 // no errors) | 1460 // no errors) |
1459 | 1461 |
1460 // Handle crashes and timeouts first | 1462 // Handle crashes and timeouts first |
1461 if (hasCrashed) return Expectation.CRASH; | 1463 if (hasCrashed) return Expectation.crash; |
1462 if (hasTimedOut) return Expectation.TIMEOUT; | 1464 if (hasTimedOut) return Expectation.timeout; |
1463 if (hasNonUtf8) return Expectation.NON_UTF8_ERROR; | 1465 if (hasNonUtf8) return Expectation.nonUtf8Error; |
1464 | 1466 |
1465 // Get the errors/warnings from the analyzer | 1467 // Get the errors/warnings from the analyzer |
1466 List<String> errors = []; | 1468 List<String> errors = []; |
1467 List<String> warnings = []; | 1469 List<String> warnings = []; |
1468 parseAnalyzerOutput(errors, warnings); | 1470 parseAnalyzerOutput(errors, warnings); |
1469 | 1471 |
1470 // Handle errors / missing errors | 1472 // Handle errors / missing errors |
1471 if (testCase.expectCompileError) { | 1473 if (testCase.expectCompileError) { |
1472 if (errors.length > 0) { | 1474 if (errors.length > 0) { |
1473 return Expectation.PASS; | 1475 return Expectation.pass; |
1474 } | 1476 } |
1475 return Expectation.MISSING_COMPILETIME_ERROR; | 1477 return Expectation.missingCompileTimeError; |
1476 } | 1478 } |
1477 if (errors.length > 0) { | 1479 if (errors.length > 0) { |
1478 return Expectation.COMPILETIME_ERROR; | 1480 return Expectation.compileTimeError; |
1479 } | 1481 } |
1480 | 1482 |
1481 // Handle static warnings / missing static warnings | 1483 // Handle static warnings / missing static warnings |
1482 if (testCase.hasStaticWarning) { | 1484 if (testCase.hasStaticWarning) { |
1483 if (warnings.length > 0) { | 1485 if (warnings.length > 0) { |
1484 return Expectation.PASS; | 1486 return Expectation.pass; |
1485 } | 1487 } |
1486 return Expectation.MISSING_STATIC_WARNING; | 1488 return Expectation.missingStaticWarning; |
1487 } | 1489 } |
1488 if (warnings.length > 0) { | 1490 if (warnings.length > 0) { |
1489 return Expectation.STATIC_WARNING; | 1491 return Expectation.staticWarning; |
1490 } | 1492 } |
1491 | 1493 |
1492 assert(errors.length == 0 && warnings.length == 0); | 1494 assert(errors.length == 0 && warnings.length == 0); |
1493 assert(!testCase.hasCompileError && !testCase.hasStaticWarning); | 1495 assert(!testCase.hasCompileError && !testCase.hasStaticWarning); |
1494 return Expectation.PASS; | 1496 return Expectation.pass; |
1495 } | 1497 } |
1496 | 1498 |
1497 void parseAnalyzerOutput(List<String> outErrors, List<String> outWarnings) { | 1499 void parseAnalyzerOutput(List<String> outErrors, List<String> outWarnings) { |
1498 // Parse a line delimited by the | character using \ as an escape character | 1500 // Parse a line delimited by the | character using \ as an escape character |
1499 // like: FOO|BAR|FOO\|BAR|FOO\\BAZ as 4 fields: FOO BAR FOO|BAR FOO\BAZ | 1501 // like: FOO|BAR|FOO\|BAR|FOO\\BAZ as 4 fields: FOO BAR FOO|BAR FOO\BAZ |
1500 List<String> splitMachineError(String line) { | 1502 List<String> splitMachineError(String line) { |
1501 StringBuffer field = new StringBuffer(); | 1503 StringBuffer field = new StringBuffer(); |
1502 List<String> result = []; | 1504 List<String> result = []; |
1503 bool escaped = false; | 1505 bool escaped = false; |
1504 for (var i = 0; i < line.length; i++) { | 1506 for (var i = 0; i < line.length; i++) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1540 static const DART_VM_EXITCODE_DFE_ERROR = 252; | 1542 static const DART_VM_EXITCODE_DFE_ERROR = 252; |
1541 static const DART_VM_EXITCODE_COMPILE_TIME_ERROR = 254; | 1543 static const DART_VM_EXITCODE_COMPILE_TIME_ERROR = 254; |
1542 static const DART_VM_EXITCODE_UNCAUGHT_EXCEPTION = 255; | 1544 static const DART_VM_EXITCODE_UNCAUGHT_EXCEPTION = 255; |
1543 | 1545 |
1544 VmCommandOutputImpl(Command command, int exitCode, bool timedOut, | 1546 VmCommandOutputImpl(Command command, int exitCode, bool timedOut, |
1545 List<int> stdout, List<int> stderr, Duration time, int pid) | 1547 List<int> stdout, List<int> stderr, Duration time, int pid) |
1546 : super(command, exitCode, timedOut, stdout, stderr, time, false, pid); | 1548 : super(command, exitCode, timedOut, stdout, stderr, time, false, pid); |
1547 | 1549 |
1548 Expectation result(TestCase testCase) { | 1550 Expectation result(TestCase testCase) { |
1549 // Handle crashes and timeouts first | 1551 // Handle crashes and timeouts first |
1550 if (exitCode == DART_VM_EXITCODE_DFE_ERROR) return Expectation.DARTK_CRASH; | 1552 if (exitCode == DART_VM_EXITCODE_DFE_ERROR) return Expectation.dartkCrash; |
1551 if (hasCrashed) return Expectation.CRASH; | 1553 if (hasCrashed) return Expectation.crash; |
1552 if (hasTimedOut) return Expectation.TIMEOUT; | 1554 if (hasTimedOut) return Expectation.timeout; |
1553 if (hasNonUtf8) return Expectation.NON_UTF8_ERROR; | 1555 if (hasNonUtf8) return Expectation.nonUtf8Error; |
1554 | 1556 |
1555 // Multitests are handled specially | 1557 // Multitests are handled specially |
1556 if (testCase.expectCompileError) { | 1558 if (testCase.expectCompileError) { |
1557 if (exitCode == DART_VM_EXITCODE_COMPILE_TIME_ERROR) { | 1559 if (exitCode == DART_VM_EXITCODE_COMPILE_TIME_ERROR) { |
1558 return Expectation.PASS; | 1560 return Expectation.pass; |
1559 } | 1561 } |
1560 return Expectation.MISSING_COMPILETIME_ERROR; | 1562 return Expectation.missingCompileTimeError; |
1561 } | 1563 } |
1562 if (testCase.hasRuntimeError) { | 1564 if (testCase.hasRuntimeError) { |
1563 // TODO(kustermann): Do we consider a "runtimeError" only an uncaught | 1565 // TODO(kustermann): Do we consider a "runtimeError" only an uncaught |
1564 // exception or does any nonzero exit code fullfil this requirement? | 1566 // exception or does any nonzero exit code fullfil this requirement? |
1565 if (exitCode != 0) { | 1567 if (exitCode != 0) { |
1566 return Expectation.PASS; | 1568 return Expectation.pass; |
1567 } | 1569 } |
1568 return Expectation.MISSING_RUNTIME_ERROR; | 1570 return Expectation.missingRuntimeError; |
1569 } | 1571 } |
1570 | 1572 |
1571 // The actual outcome depends on the exitCode | 1573 // The actual outcome depends on the exitCode |
1572 Expectation outcome; | 1574 Expectation outcome; |
1573 if (exitCode == DART_VM_EXITCODE_COMPILE_TIME_ERROR) { | 1575 if (exitCode == DART_VM_EXITCODE_COMPILE_TIME_ERROR) { |
1574 outcome = Expectation.COMPILETIME_ERROR; | 1576 outcome = Expectation.compileTimeError; |
1575 } else if (exitCode == DART_VM_EXITCODE_UNCAUGHT_EXCEPTION) { | 1577 } else if (exitCode == DART_VM_EXITCODE_UNCAUGHT_EXCEPTION) { |
1576 outcome = Expectation.RUNTIME_ERROR; | 1578 outcome = Expectation.runtimeError; |
1577 } else if (exitCode != 0) { | 1579 } else if (exitCode != 0) { |
1578 // This is a general fail, in case we get an unknown nonzero exitcode. | 1580 // This is a general fail, in case we get an unknown nonzero exitcode. |
1579 outcome = Expectation.FAIL; | 1581 outcome = Expectation.fail; |
1580 } else { | 1582 } else { |
1581 outcome = Expectation.PASS; | 1583 outcome = Expectation.pass; |
1582 } | 1584 } |
1583 outcome = _negateOutcomeIfIncompleteAsyncTest(outcome, decodeUtf8(stdout)); | 1585 outcome = _negateOutcomeIfIncompleteAsyncTest(outcome, decodeUtf8(stdout)); |
1584 return _negateOutcomeIfNegativeTest(outcome, testCase.isNegative); | 1586 return _negateOutcomeIfNegativeTest(outcome, testCase.isNegative); |
1585 } | 1587 } |
1586 } | 1588 } |
1587 | 1589 |
1588 class CompilationCommandOutputImpl extends CommandOutputImpl { | 1590 class CompilationCommandOutputImpl extends CommandOutputImpl { |
1589 static const DART2JS_EXITCODE_CRASH = 253; | 1591 static const DART2JS_EXITCODE_CRASH = 253; |
1590 | 1592 |
1591 CompilationCommandOutputImpl( | 1593 CompilationCommandOutputImpl( |
1592 Command command, | 1594 Command command, |
1593 int exitCode, | 1595 int exitCode, |
1594 bool timedOut, | 1596 bool timedOut, |
1595 List<int> stdout, | 1597 List<int> stdout, |
1596 List<int> stderr, | 1598 List<int> stderr, |
1597 Duration time, | 1599 Duration time, |
1598 bool compilationSkipped) | 1600 bool compilationSkipped) |
1599 : super(command, exitCode, timedOut, stdout, stderr, time, | 1601 : super(command, exitCode, timedOut, stdout, stderr, time, |
1600 compilationSkipped, 0); | 1602 compilationSkipped, 0); |
1601 | 1603 |
1602 Expectation result(TestCase testCase) { | 1604 Expectation result(TestCase testCase) { |
1603 // Handle general crash/timeout detection. | 1605 // Handle general crash/timeout detection. |
1604 if (hasCrashed) return Expectation.CRASH; | 1606 if (hasCrashed) return Expectation.crash; |
1605 if (hasTimedOut) { | 1607 if (hasTimedOut) { |
1606 bool isWindows = io.Platform.operatingSystem == 'windows'; | 1608 bool isWindows = io.Platform.operatingSystem == 'windows'; |
1607 bool isBrowserTestCase = | 1609 bool isBrowserTestCase = |
1608 testCase.commands.any((command) => command is BrowserTestCommand); | 1610 testCase.commands.any((command) => command is BrowserTestCommand); |
1609 // TODO(26060) Dart2js batch mode hangs on Windows under heavy load. | 1611 // TODO(26060) Dart2js batch mode hangs on Windows under heavy load. |
1610 return (isWindows && isBrowserTestCase) | 1612 return (isWindows && isBrowserTestCase) |
1611 ? Expectation.IGNORE | 1613 ? Expectation.ignore |
1612 : Expectation.TIMEOUT; | 1614 : Expectation.timeout; |
1613 } | 1615 } |
1614 if (hasNonUtf8) return Expectation.NON_UTF8_ERROR; | 1616 if (hasNonUtf8) return Expectation.nonUtf8Error; |
1615 | 1617 |
1616 // Handle dart2js specific crash detection | 1618 // Handle dart2js specific crash detection |
1617 if (exitCode == DART2JS_EXITCODE_CRASH || | 1619 if (exitCode == DART2JS_EXITCODE_CRASH || |
1618 exitCode == VmCommandOutputImpl.DART_VM_EXITCODE_COMPILE_TIME_ERROR || | 1620 exitCode == VmCommandOutputImpl.DART_VM_EXITCODE_COMPILE_TIME_ERROR || |
1619 exitCode == VmCommandOutputImpl.DART_VM_EXITCODE_UNCAUGHT_EXCEPTION) { | 1621 exitCode == VmCommandOutputImpl.DART_VM_EXITCODE_UNCAUGHT_EXCEPTION) { |
1620 return Expectation.CRASH; | 1622 return Expectation.crash; |
1621 } | 1623 } |
1622 | 1624 |
1623 // Multitests are handled specially | 1625 // Multitests are handled specially |
1624 if (testCase.expectCompileError) { | 1626 if (testCase.expectCompileError) { |
1625 // Nonzero exit code of the compiler means compilation failed | 1627 // Nonzero exit code of the compiler means compilation failed |
1626 // TODO(kustermann): Do we have a special exit code in that case??? | 1628 // TODO(kustermann): Do we have a special exit code in that case??? |
1627 if (exitCode != 0) { | 1629 if (exitCode != 0) { |
1628 return Expectation.PASS; | 1630 return Expectation.pass; |
1629 } | 1631 } |
1630 return Expectation.MISSING_COMPILETIME_ERROR; | 1632 return Expectation.missingCompileTimeError; |
1631 } | 1633 } |
1632 | 1634 |
1633 // TODO(kustermann): This is a hack, remove it | 1635 // TODO(kustermann): This is a hack, remove it |
1634 if (testCase.hasRuntimeError && testCase.commands.length > 1) { | 1636 if (testCase.hasRuntimeError && testCase.commands.length > 1) { |
1635 // We expected to run the test, but we got an compile time error. | 1637 // We expected to run the test, but we got an compile time error. |
1636 // If the compilation succeeded, we wouldn't be in here! | 1638 // If the compilation succeeded, we wouldn't be in here! |
1637 assert(exitCode != 0); | 1639 assert(exitCode != 0); |
1638 return Expectation.COMPILETIME_ERROR; | 1640 return Expectation.compileTimeError; |
1639 } | 1641 } |
1640 | 1642 |
1641 Expectation outcome = | 1643 Expectation outcome = |
1642 exitCode == 0 ? Expectation.PASS : Expectation.COMPILETIME_ERROR; | 1644 exitCode == 0 ? Expectation.pass : Expectation.compileTimeError; |
1643 return _negateOutcomeIfNegativeTest(outcome, testCase.isNegative); | 1645 return _negateOutcomeIfNegativeTest(outcome, testCase.isNegative); |
1644 } | 1646 } |
1645 } | 1647 } |
1646 | 1648 |
1647 class KernelCompilationCommandOutputImpl extends CompilationCommandOutputImpl { | 1649 class KernelCompilationCommandOutputImpl extends CompilationCommandOutputImpl { |
1648 KernelCompilationCommandOutputImpl( | 1650 KernelCompilationCommandOutputImpl( |
1649 Command command, | 1651 Command command, |
1650 int exitCode, | 1652 int exitCode, |
1651 bool timedOut, | 1653 bool timedOut, |
1652 List<int> stdout, | 1654 List<int> stdout, |
1653 List<int> stderr, | 1655 List<int> stderr, |
1654 Duration time, | 1656 Duration time, |
1655 bool compilationSkipped) | 1657 bool compilationSkipped) |
1656 : super(command, exitCode, timedOut, stdout, stderr, time, | 1658 : super(command, exitCode, timedOut, stdout, stderr, time, |
1657 compilationSkipped); | 1659 compilationSkipped); |
1658 | 1660 |
1659 bool get canRunDependendCommands { | 1661 bool get canRunDependendCommands { |
1660 // See [BatchRunnerProcess]: 0 means success, 1 means compile-time error. | 1662 // See [BatchRunnerProcess]: 0 means success, 1 means compile-time error. |
1661 // TODO(asgerf): When the frontend supports it, continue running even if | 1663 // TODO(asgerf): When the frontend supports it, continue running even if |
1662 // there were compile-time errors. See kernel_sdk issue #18. | 1664 // there were compile-time errors. See kernel_sdk issue #18. |
1663 return !hasCrashed && !timedOut && exitCode == 0; | 1665 return !hasCrashed && !timedOut && exitCode == 0; |
1664 } | 1666 } |
1665 | 1667 |
1666 Expectation result(TestCase testCase) { | 1668 Expectation result(TestCase testCase) { |
1667 Expectation result = super.result(testCase); | 1669 Expectation result = super.result(testCase); |
1668 if (result.canBeOutcomeOf(Expectation.CRASH)) { | 1670 if (result.canBeOutcomeOf(Expectation.crash)) { |
1669 return Expectation.DARTK_CRASH; | 1671 return Expectation.dartkCrash; |
1670 } else if (result.canBeOutcomeOf(Expectation.TIMEOUT)) { | 1672 } else if (result.canBeOutcomeOf(Expectation.timeout)) { |
1671 return Expectation.DARTK_TIMEOUT; | 1673 return Expectation.dartkTimeout; |
1672 } else if (result.canBeOutcomeOf(Expectation.COMPILETIME_ERROR)) { | 1674 } else if (result.canBeOutcomeOf(Expectation.compileTimeError)) { |
1673 return Expectation.DARTK_COMPILETIME_ERROR; | 1675 return Expectation.dartkCompileTimeError; |
1674 } | 1676 } |
1675 return result; | 1677 return result; |
1676 } | 1678 } |
1677 | 1679 |
1678 // If the compiler was able to produce a Kernel IR file we want to run the | 1680 // If the compiler was able to produce a Kernel IR file we want to run the |
1679 // result on the Dart VM. We therefore mark the [KernelCompilationCommand] as | 1681 // result on the Dart VM. We therefore mark the [KernelCompilationCommand] as |
1680 // successful. | 1682 // successful. |
1681 // => This ensures we test that the DartVM produces correct CompileTime errors | 1683 // => This ensures we test that the DartVM produces correct CompileTime errors |
1682 // as it is supposed to for our test suites. | 1684 // as it is supposed to for our test suites. |
1683 bool get successful => canRunDependendCommands; | 1685 bool get successful => canRunDependendCommands; |
1684 } | 1686 } |
1685 | 1687 |
1686 class JsCommandlineOutputImpl extends CommandOutputImpl | 1688 class JsCommandlineOutputImpl extends CommandOutputImpl |
1687 with UnittestSuiteMessagesMixin { | 1689 with UnittestSuiteMessagesMixin { |
1688 JsCommandlineOutputImpl(Command command, int exitCode, bool timedOut, | 1690 JsCommandlineOutputImpl(Command command, int exitCode, bool timedOut, |
1689 List<int> stdout, List<int> stderr, Duration time) | 1691 List<int> stdout, List<int> stderr, Duration time) |
1690 : super(command, exitCode, timedOut, stdout, stderr, time, false, 0); | 1692 : super(command, exitCode, timedOut, stdout, stderr, time, false, 0); |
1691 | 1693 |
1692 Expectation result(TestCase testCase) { | 1694 Expectation result(TestCase testCase) { |
1693 // Handle crashes and timeouts first | 1695 // Handle crashes and timeouts first |
1694 if (hasCrashed) return Expectation.CRASH; | 1696 if (hasCrashed) return Expectation.crash; |
1695 if (hasTimedOut) return Expectation.TIMEOUT; | 1697 if (hasTimedOut) return Expectation.timeout; |
1696 if (hasNonUtf8) return Expectation.NON_UTF8_ERROR; | 1698 if (hasNonUtf8) return Expectation.nonUtf8Error; |
1697 | 1699 |
1698 if (testCase.hasRuntimeError) { | 1700 if (testCase.hasRuntimeError) { |
1699 if (exitCode != 0) return Expectation.PASS; | 1701 if (exitCode != 0) return Expectation.pass; |
1700 return Expectation.MISSING_RUNTIME_ERROR; | 1702 return Expectation.missingRuntimeError; |
1701 } | 1703 } |
1702 | 1704 |
1703 var outcome = exitCode == 0 ? Expectation.PASS : Expectation.RUNTIME_ERROR; | 1705 var outcome = exitCode == 0 ? Expectation.pass : Expectation.runtimeError; |
1704 outcome = _negateOutcomeIfIncompleteAsyncTest(outcome, decodeUtf8(stdout)); | 1706 outcome = _negateOutcomeIfIncompleteAsyncTest(outcome, decodeUtf8(stdout)); |
1705 return _negateOutcomeIfNegativeTest(outcome, testCase.isNegative); | 1707 return _negateOutcomeIfNegativeTest(outcome, testCase.isNegative); |
1706 } | 1708 } |
1707 } | 1709 } |
1708 | 1710 |
1709 class PubCommandOutputImpl extends CommandOutputImpl { | 1711 class PubCommandOutputImpl extends CommandOutputImpl { |
1710 PubCommandOutputImpl(PubCommand command, int exitCode, bool timedOut, | 1712 PubCommandOutputImpl(PubCommand command, int exitCode, bool timedOut, |
1711 List<int> stdout, List<int> stderr, Duration time) | 1713 List<int> stdout, List<int> stderr, Duration time) |
1712 : super(command, exitCode, timedOut, stdout, stderr, time, false, 0); | 1714 : super(command, exitCode, timedOut, stdout, stderr, time, false, 0); |
1713 | 1715 |
1714 Expectation result(TestCase testCase) { | 1716 Expectation result(TestCase testCase) { |
1715 // Handle crashes and timeouts first | 1717 // Handle crashes and timeouts first |
1716 if (hasCrashed) return Expectation.CRASH; | 1718 if (hasCrashed) return Expectation.crash; |
1717 if (hasTimedOut) return Expectation.TIMEOUT; | 1719 if (hasTimedOut) return Expectation.timeout; |
1718 if (hasNonUtf8) return Expectation.NON_UTF8_ERROR; | 1720 if (hasNonUtf8) return Expectation.nonUtf8Error; |
1719 | 1721 |
1720 if (exitCode == 0) { | 1722 if (exitCode == 0) { |
1721 return Expectation.PASS; | 1723 return Expectation.pass; |
1722 } else if ((command as PubCommand).command == 'get') { | 1724 } else if ((command as PubCommand).command == 'get') { |
1723 return Expectation.PUB_GET_ERROR; | 1725 return Expectation.pubGetError; |
1724 } else { | 1726 } else { |
1725 return Expectation.FAIL; | 1727 return Expectation.fail; |
1726 } | 1728 } |
1727 } | 1729 } |
1728 } | 1730 } |
1729 | 1731 |
1730 class ScriptCommandOutputImpl extends CommandOutputImpl { | 1732 class ScriptCommandOutputImpl extends CommandOutputImpl { |
1731 final Expectation _result; | 1733 final Expectation _result; |
1732 | 1734 |
1733 ScriptCommandOutputImpl(ScriptCommand command, this._result, | 1735 ScriptCommandOutputImpl(ScriptCommand command, this._result, |
1734 String scriptExecutionInformation, Duration time) | 1736 String scriptExecutionInformation, Duration time) |
1735 : super(command, 0, false, [], [], time, false, 0) { | 1737 : super(command, 0, false, [], [], time, false, 0) { |
1736 var lines = scriptExecutionInformation.split("\n"); | 1738 var lines = scriptExecutionInformation.split("\n"); |
1737 diagnostics.addAll(lines); | 1739 diagnostics.addAll(lines); |
1738 } | 1740 } |
1739 | 1741 |
1740 Expectation result(TestCase testCase) => _result; | 1742 Expectation result(TestCase testCase) => _result; |
1741 | 1743 |
1742 bool get canRunDependendCommands => _result == Expectation.PASS; | 1744 bool get canRunDependendCommands => _result == Expectation.pass; |
1743 | 1745 |
1744 bool get successful => _result == Expectation.PASS; | 1746 bool get successful => _result == Expectation.pass; |
1745 } | 1747 } |
1746 | 1748 |
1747 CommandOutput createCommandOutput(Command command, int exitCode, bool timedOut, | 1749 CommandOutput createCommandOutput(Command command, int exitCode, bool timedOut, |
1748 List<int> stdout, List<int> stderr, Duration time, bool compilationSkipped, | 1750 List<int> stdout, List<int> stderr, Duration time, bool compilationSkipped, |
1749 [int pid = 0]) { | 1751 [int pid = 0]) { |
1750 if (command is ContentShellCommand) { | 1752 if (command is ContentShellCommand) { |
1751 return new BrowserCommandOutputImpl( | 1753 return new BrowserCommandOutputImpl( |
1752 command, exitCode, timedOut, stdout, stderr, time, compilationSkipped); | 1754 command, exitCode, timedOut, stdout, stderr, time, compilationSkipped); |
1753 } else if (command is BrowserTestCommand) { | 1755 } else if (command is BrowserTestCommand) { |
1754 return new HTMLBrowserCommandOutputImpl( | 1756 return new HTMLBrowserCommandOutputImpl( |
(...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3289 } | 3291 } |
3290 } | 3292 } |
3291 | 3293 |
3292 void eventAllTestsDone() { | 3294 void eventAllTestsDone() { |
3293 for (var listener in _eventListener) { | 3295 for (var listener in _eventListener) { |
3294 listener.allDone(); | 3296 listener.allDone(); |
3295 } | 3297 } |
3296 _allDone(); | 3298 _allDone(); |
3297 } | 3299 } |
3298 } | 3300 } |
OLD | NEW |