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"; | |
26 import "path.dart"; | 25 import "path.dart"; |
27 import 'record_and_replay.dart'; | 26 import 'record_and_replay.dart'; |
28 import "runtime_configuration.dart"; | 27 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.skipByDesign)) { | 853 expectedOutcomes.contains(Expectation.SKIP_BY_DESIGN)) { |
854 return false; | 854 return false; |
855 } | 855 } |
856 | 856 |
857 return expectedOutcomes | 857 return expectedOutcomes |
858 .where((expectation) => expectation.isOutcome) | 858 .where((expectation) => !expectation.isMetaExpectation) |
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.nonUtf8Error; | 988 if (hasNonUtf8) return Expectation.NON_UTF8_ERROR; |
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. | |
1054 static int WHITELISTED_CONTENTSHELL_EXITCODE = -1073740022; | 1053 static int WHITELISTED_CONTENTSHELL_EXITCODE = -1073740022; |
1055 static bool isWindows = io.Platform.operatingSystem == 'windows'; | 1054 static bool isWindows = io.Platform.operatingSystem == 'windows'; |
1056 static bool _failedBecauseOfFlakyInfrastructure( | 1055 static bool _failedBecauseOfFlakyInfrastructure( |
1057 Command command, bool timedOut, List<int> stderrBytes) { | 1056 Command command, bool timedOut, List<int> stderrBytes) { |
1058 // If the browser test failed, it may have been because content shell | 1057 // If the browser test failed, it may have been because content shell |
1059 // and the virtual framebuffer X server didn't hook up, or it crashed with | 1058 // and the virtual framebuffer X server didn't hook up, or it crashed with |
1060 // a core dump. Sometimes content shell crashes after it has set the stdout | 1059 // a core dump. Sometimes content shell crashes after it has set the stdout |
1061 // to PASS, so we have to do this check first. | 1060 // to PASS, so we have to do this check first. |
1062 // Content shell also fails with a broken pipe message: Issue 26739 | 1061 // Content shell also fails with a broken pipe message: Issue 26739 |
1063 var zygoteCrash = | 1062 var zygoteCrash = |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1097 List<int> stderr, | 1096 List<int> stderr, |
1098 Duration time, | 1097 Duration time, |
1099 bool compilationSkipped) | 1098 bool compilationSkipped) |
1100 : _infraFailure = | 1099 : _infraFailure = |
1101 _failedBecauseOfFlakyInfrastructure(command, timedOut, stderr), | 1100 _failedBecauseOfFlakyInfrastructure(command, timedOut, stderr), |
1102 super(command, exitCode, timedOut, stdout, stderr, time, | 1101 super(command, exitCode, timedOut, stdout, stderr, time, |
1103 compilationSkipped, 0); | 1102 compilationSkipped, 0); |
1104 | 1103 |
1105 Expectation result(TestCase testCase) { | 1104 Expectation result(TestCase testCase) { |
1106 if (_infraFailure) { | 1105 if (_infraFailure) { |
1107 return Expectation.ignore; | 1106 return Expectation.IGNORE; |
1108 } | 1107 } |
1109 | |
1110 // Handle crashes and timeouts first | 1108 // Handle crashes and timeouts first |
1111 if (hasCrashed) return Expectation.crash; | 1109 if (hasCrashed) return Expectation.CRASH; |
1112 if (hasTimedOut) return Expectation.timeout; | 1110 if (hasTimedOut) return Expectation.TIMEOUT; |
1113 if (hasNonUtf8) return Expectation.nonUtf8Error; | 1111 if (hasNonUtf8) return Expectation.NON_UTF8_ERROR; |
1114 | 1112 |
1115 var outcome = _getOutcome(); | 1113 var outcome = _getOutcome(); |
1116 | 1114 |
1117 if (testCase.hasRuntimeError) { | 1115 if (testCase.hasRuntimeError) { |
1118 if (!outcome.canBeOutcomeOf(Expectation.runtimeError)) { | 1116 if (!outcome.canBeOutcomeOf(Expectation.RUNTIME_ERROR)) { |
1119 return Expectation.missingRuntimeError; | 1117 return Expectation.MISSING_RUNTIME_ERROR; |
1120 } | 1118 } |
1121 } | 1119 } |
1122 if (testCase.isNegative) { | 1120 if (testCase.isNegative) { |
1123 if (outcome.canBeOutcomeOf(Expectation.fail)) return Expectation.pass; | 1121 if (outcome.canBeOutcomeOf(Expectation.FAIL)) return Expectation.PASS; |
1124 return Expectation.fail; | 1122 return Expectation.FAIL; |
1125 } | 1123 } |
1126 return outcome; | 1124 return outcome; |
1127 } | 1125 } |
1128 | 1126 |
1129 bool get successful => canRunDependendCommands; | 1127 bool get successful => canRunDependendCommands; |
1130 | 1128 |
1131 bool get canRunDependendCommands { | 1129 bool get canRunDependendCommands { |
1132 // We cannot rely on the exit code of content_shell as a method to | 1130 // We cannot rely on the exit code of content_shell as a method to |
1133 // determine if we were successful or not. | 1131 // determine if we were successful or not. |
1134 return super.canRunDependendCommands && !didFail(null); | 1132 return super.canRunDependendCommands && !didFail(null); |
1135 } | 1133 } |
1136 | 1134 |
1137 bool get hasCrashed { | 1135 bool get hasCrashed { |
1138 return super.hasCrashed || _rendererCrashed; | 1136 return super.hasCrashed || _rendererCrashed; |
1139 } | 1137 } |
1140 | 1138 |
1141 Expectation _getOutcome() { | 1139 Expectation _getOutcome() { |
1142 if (_browserTestFailure) { | 1140 if (_browserTestFailure) { |
1143 return Expectation.runtimeError; | 1141 return Expectation.RUNTIME_ERROR; |
1144 } | 1142 } |
1145 return Expectation.pass; | 1143 return Expectation.PASS; |
1146 } | 1144 } |
1147 | 1145 |
1148 bool get _rendererCrashed => | 1146 bool get _rendererCrashed => |
1149 decodeUtf8(super.stdout).contains("#CRASHED - rendere"); | 1147 decodeUtf8(super.stdout).contains("#CRASHED - rendere"); |
1150 | 1148 |
1151 bool get _browserTestFailure { | 1149 bool get _browserTestFailure { |
1152 // Browser tests fail unless stdout contains | 1150 // Browser tests fail unless stdout contains |
1153 // 'Content-Type: text/plain' followed by 'PASS'. | 1151 // 'Content-Type: text/plain' followed by 'PASS'. |
1154 bool hasContentType = false; | 1152 bool hasContentType = false; |
1155 var stdoutLines = decodeUtf8(super.stdout).split("\n"); | 1153 var stdoutLines = decodeUtf8(super.stdout).split("\n"); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1208 int exitCode, | 1206 int exitCode, |
1209 bool timedOut, | 1207 bool timedOut, |
1210 List<int> stdout, | 1208 List<int> stdout, |
1211 List<int> stderr, | 1209 List<int> stderr, |
1212 Duration time, | 1210 Duration time, |
1213 bool compilationSkipped) | 1211 bool compilationSkipped) |
1214 : super(command, exitCode, timedOut, stdout, stderr, time, | 1212 : super(command, exitCode, timedOut, stdout, stderr, time, |
1215 compilationSkipped); | 1213 compilationSkipped); |
1216 | 1214 |
1217 bool didFail(TestCase testCase) { | 1215 bool didFail(TestCase testCase) { |
1218 return _getOutcome() != Expectation.pass; | 1216 return _getOutcome() != Expectation.PASS; |
1219 } | 1217 } |
1220 | 1218 |
1221 bool get _browserTestFailure { | 1219 bool get _browserTestFailure { |
1222 // We should not need to convert back and forward. | 1220 // We should not need to convert back and forward. |
1223 var output = decodeUtf8(super.stdout); | 1221 var output = decodeUtf8(super.stdout); |
1224 if (output.contains("FAIL")) return true; | 1222 if (output.contains("FAIL")) return true; |
1225 return !output.contains("PASS"); | 1223 return !output.contains("PASS"); |
1226 } | 1224 } |
1227 } | 1225 } |
1228 | 1226 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1299 static Expectation _getOutcome(Map<String, List<String>> messagesByType) { | 1297 static Expectation _getOutcome(Map<String, List<String>> messagesByType) { |
1300 occured(String type) => messagesByType[type].length > 0; | 1298 occured(String type) => messagesByType[type].length > 0; |
1301 searchForMsg(List<String> types, String message) { | 1299 searchForMsg(List<String> types, String message) { |
1302 return types.any((type) => messagesByType[type].contains(message)); | 1300 return types.any((type) => messagesByType[type].contains(message)); |
1303 } | 1301 } |
1304 | 1302 |
1305 // FIXME(kustermann,ricow): I think this functionality doesn't work in | 1303 // FIXME(kustermann,ricow): I think this functionality doesn't work in |
1306 // test_controller.js: So far I haven't seen anything being reported on | 1304 // test_controller.js: So far I haven't seen anything being reported on |
1307 // "window.compilationerror" | 1305 // "window.compilationerror" |
1308 if (occured('window_compilationerror')) { | 1306 if (occured('window_compilationerror')) { |
1309 return Expectation.compileTimeError; | 1307 return Expectation.COMPILETIME_ERROR; |
1310 } | 1308 } |
1311 | 1309 |
1312 if (occured('sync_exception') || | 1310 if (occured('sync_exception') || |
1313 occured('window_onerror') || | 1311 occured('window_onerror') || |
1314 occured('script_onerror')) { | 1312 occured('script_onerror')) { |
1315 return Expectation.runtimeError; | 1313 return Expectation.RUNTIME_ERROR; |
1316 } | 1314 } |
1317 | 1315 |
1318 if (messagesByType['dom'][0].contains('FAIL')) { | 1316 if (messagesByType['dom'][0].contains('FAIL')) { |
1319 return Expectation.runtimeError; | 1317 return Expectation.RUNTIME_ERROR; |
1320 } | 1318 } |
1321 | 1319 |
1322 // We search for these messages in 'print' and 'message_received' because | 1320 // We search for these messages in 'print' and 'message_received' because |
1323 // the unittest implementation posts these messages using | 1321 // the unittest implementation posts these messages using |
1324 // "window.postMessage()" instead of the normal "print()" them. | 1322 // "window.postMessage()" instead of the normal "print()" them. |
1325 | 1323 |
1326 var isAsyncTest = searchForMsg( | 1324 var isAsyncTest = searchForMsg( |
1327 ['print', 'message_received'], 'unittest-suite-wait-for-done'); | 1325 ['print', 'message_received'], 'unittest-suite-wait-for-done'); |
1328 var isAsyncSuccess = | 1326 var isAsyncSuccess = |
1329 searchForMsg(['print', 'message_received'], 'unittest-suite-success') || | 1327 searchForMsg(['print', 'message_received'], 'unittest-suite-success') || |
1330 searchForMsg(['print', 'message_received'], 'unittest-suite-done'); | 1328 searchForMsg(['print', 'message_received'], 'unittest-suite-done'); |
1331 | 1329 |
1332 if (isAsyncTest) { | 1330 if (isAsyncTest) { |
1333 if (isAsyncSuccess) { | 1331 if (isAsyncSuccess) { |
1334 return Expectation.pass; | 1332 return Expectation.PASS; |
1335 } | 1333 } |
1336 return Expectation.runtimeError; | 1334 return Expectation.RUNTIME_ERROR; |
1337 } | 1335 } |
1338 | 1336 |
1339 var mainStarted = | 1337 var mainStarted = |
1340 searchForMsg(['print', 'message_received'], 'dart-calling-main'); | 1338 searchForMsg(['print', 'message_received'], 'dart-calling-main'); |
1341 var mainDone = | 1339 var mainDone = |
1342 searchForMsg(['print', 'message_received'], 'dart-main-done'); | 1340 searchForMsg(['print', 'message_received'], 'dart-main-done'); |
1343 | 1341 |
1344 if (mainStarted && mainDone) { | 1342 if (mainStarted && mainDone) { |
1345 return Expectation.pass; | 1343 return Expectation.PASS; |
1346 } | 1344 } |
1347 return Expectation.fail; | 1345 return Expectation.FAIL; |
1348 } | 1346 } |
1349 } | 1347 } |
1350 | 1348 |
1351 class BrowserControllerTestOutcome extends CommandOutputImpl | 1349 class BrowserControllerTestOutcome extends CommandOutputImpl |
1352 with UnittestSuiteMessagesMixin { | 1350 with UnittestSuiteMessagesMixin { |
1353 BrowserTestOutput _result; | 1351 BrowserTestOutput _result; |
1354 Expectation _rawOutcome; | 1352 Expectation _rawOutcome; |
1355 | 1353 |
1356 factory BrowserControllerTestOutcome( | 1354 factory BrowserControllerTestOutcome( |
1357 Command command, BrowserTestOutput result) { | 1355 Command command, BrowserTestOutput result) { |
(...skipping 10 matching lines...) Expand all Loading... |
1368 String stderr = ""; | 1366 String stderr = ""; |
1369 Expectation outcome; | 1367 Expectation outcome; |
1370 | 1368 |
1371 var parsedResult = | 1369 var parsedResult = |
1372 BrowserTestJsonResult.parseFromString(result.lastKnownMessage); | 1370 BrowserTestJsonResult.parseFromString(result.lastKnownMessage); |
1373 if (parsedResult != null) { | 1371 if (parsedResult != null) { |
1374 outcome = parsedResult.outcome; | 1372 outcome = parsedResult.outcome; |
1375 } else { | 1373 } else { |
1376 // Old way of determining whether a test failed or passed. | 1374 // Old way of determining whether a test failed or passed. |
1377 if (result.lastKnownMessage.contains("FAIL")) { | 1375 if (result.lastKnownMessage.contains("FAIL")) { |
1378 outcome = Expectation.runtimeError; | 1376 outcome = Expectation.RUNTIME_ERROR; |
1379 } else if (result.lastKnownMessage.contains("PASS")) { | 1377 } else if (result.lastKnownMessage.contains("PASS")) { |
1380 outcome = Expectation.pass; | 1378 outcome = Expectation.PASS; |
1381 } else { | 1379 } else { |
1382 outcome = Expectation.runtimeError; | 1380 outcome = Expectation.RUNTIME_ERROR; |
1383 } | 1381 } |
1384 } | 1382 } |
1385 | 1383 |
1386 if (result.didTimeout) { | 1384 if (result.didTimeout) { |
1387 if (result.delayUntilTestStarted != null) { | 1385 if (result.delayUntilTestStarted != null) { |
1388 stderr = "This test timed out. The delay until the test actually " | 1386 stderr = "This test timed out. The delay until the test actually " |
1389 "started was: ${result.delayUntilTestStarted}."; | 1387 "started was: ${result.delayUntilTestStarted}."; |
1390 } else { | 1388 } else { |
1391 stderr = "This test has not notified test.py that it started running."; | 1389 stderr = "This test has not notified test.py that it started running."; |
1392 } | 1390 } |
(...skipping 22 matching lines...) Expand all Loading... |
1415 this._rawOutcome, | 1413 this._rawOutcome, |
1416 List<int> stdout, | 1414 List<int> stdout, |
1417 List<int> stderr) | 1415 List<int> stderr) |
1418 : super(command, 0, result.didTimeout, stdout, stderr, result.duration, | 1416 : super(command, 0, result.didTimeout, stdout, stderr, result.duration, |
1419 false, 0) { | 1417 false, 0) { |
1420 _result = result; | 1418 _result = result; |
1421 } | 1419 } |
1422 | 1420 |
1423 Expectation result(TestCase testCase) { | 1421 Expectation result(TestCase testCase) { |
1424 // Handle timeouts first | 1422 // Handle timeouts first |
1425 if (_result.didTimeout) return Expectation.timeout; | 1423 if (_result.didTimeout) return Expectation.TIMEOUT; |
1426 if (hasNonUtf8) return Expectation.nonUtf8Error; | 1424 if (hasNonUtf8) return Expectation.NON_UTF8_ERROR; |
1427 | 1425 |
1428 // Multitests are handled specially | 1426 // Multitests are handled specially |
1429 if (testCase.hasRuntimeError) { | 1427 if (testCase.hasRuntimeError) { |
1430 if (_rawOutcome == Expectation.runtimeError) return Expectation.pass; | 1428 if (_rawOutcome == Expectation.RUNTIME_ERROR) return Expectation.PASS; |
1431 return Expectation.missingRuntimeError; | 1429 return Expectation.MISSING_RUNTIME_ERROR; |
1432 } | 1430 } |
1433 | 1431 |
1434 return _negateOutcomeIfNegativeTest(_rawOutcome, testCase.isNegative); | 1432 return _negateOutcomeIfNegativeTest(_rawOutcome, testCase.isNegative); |
1435 } | 1433 } |
1436 } | 1434 } |
1437 | 1435 |
1438 class AnalysisCommandOutputImpl extends CommandOutputImpl { | 1436 class AnalysisCommandOutputImpl extends CommandOutputImpl { |
1439 // An error line has 8 fields that look like: | 1437 // An error line has 8 fields that look like: |
1440 // ERROR|COMPILER|MISSING_SOURCE|file:/tmp/t.dart|15|1|24|Missing source. | 1438 // ERROR|COMPILER|MISSING_SOURCE|file:/tmp/t.dart|15|1|24|Missing source. |
1441 final int ERROR_LEVEL = 0; | 1439 final int ERROR_LEVEL = 0; |
(...skipping 11 matching lines...) Expand all Loading... |
1453 bool compilationSkipped) | 1451 bool compilationSkipped) |
1454 : super(command, exitCode, timedOut, stdout, stderr, time, | 1452 : super(command, exitCode, timedOut, stdout, stderr, time, |
1455 compilationSkipped, 0); | 1453 compilationSkipped, 0); |
1456 | 1454 |
1457 Expectation result(TestCase testCase) { | 1455 Expectation result(TestCase testCase) { |
1458 // TODO(kustermann): If we run the analyzer not in batch mode, make sure | 1456 // TODO(kustermann): If we run the analyzer not in batch mode, make sure |
1459 // that command.exitCodes matches 2 (errors), 1 (warnings), 0 (no warnings, | 1457 // that command.exitCodes matches 2 (errors), 1 (warnings), 0 (no warnings, |
1460 // no errors) | 1458 // no errors) |
1461 | 1459 |
1462 // Handle crashes and timeouts first | 1460 // Handle crashes and timeouts first |
1463 if (hasCrashed) return Expectation.crash; | 1461 if (hasCrashed) return Expectation.CRASH; |
1464 if (hasTimedOut) return Expectation.timeout; | 1462 if (hasTimedOut) return Expectation.TIMEOUT; |
1465 if (hasNonUtf8) return Expectation.nonUtf8Error; | 1463 if (hasNonUtf8) return Expectation.NON_UTF8_ERROR; |
1466 | 1464 |
1467 // Get the errors/warnings from the analyzer | 1465 // Get the errors/warnings from the analyzer |
1468 List<String> errors = []; | 1466 List<String> errors = []; |
1469 List<String> warnings = []; | 1467 List<String> warnings = []; |
1470 parseAnalyzerOutput(errors, warnings); | 1468 parseAnalyzerOutput(errors, warnings); |
1471 | 1469 |
1472 // Handle errors / missing errors | 1470 // Handle errors / missing errors |
1473 if (testCase.expectCompileError) { | 1471 if (testCase.expectCompileError) { |
1474 if (errors.length > 0) { | 1472 if (errors.length > 0) { |
1475 return Expectation.pass; | 1473 return Expectation.PASS; |
1476 } | 1474 } |
1477 return Expectation.missingCompileTimeError; | 1475 return Expectation.MISSING_COMPILETIME_ERROR; |
1478 } | 1476 } |
1479 if (errors.length > 0) { | 1477 if (errors.length > 0) { |
1480 return Expectation.compileTimeError; | 1478 return Expectation.COMPILETIME_ERROR; |
1481 } | 1479 } |
1482 | 1480 |
1483 // Handle static warnings / missing static warnings | 1481 // Handle static warnings / missing static warnings |
1484 if (testCase.hasStaticWarning) { | 1482 if (testCase.hasStaticWarning) { |
1485 if (warnings.length > 0) { | 1483 if (warnings.length > 0) { |
1486 return Expectation.pass; | 1484 return Expectation.PASS; |
1487 } | 1485 } |
1488 return Expectation.missingStaticWarning; | 1486 return Expectation.MISSING_STATIC_WARNING; |
1489 } | 1487 } |
1490 if (warnings.length > 0) { | 1488 if (warnings.length > 0) { |
1491 return Expectation.staticWarning; | 1489 return Expectation.STATIC_WARNING; |
1492 } | 1490 } |
1493 | 1491 |
1494 assert(errors.length == 0 && warnings.length == 0); | 1492 assert(errors.length == 0 && warnings.length == 0); |
1495 assert(!testCase.hasCompileError && !testCase.hasStaticWarning); | 1493 assert(!testCase.hasCompileError && !testCase.hasStaticWarning); |
1496 return Expectation.pass; | 1494 return Expectation.PASS; |
1497 } | 1495 } |
1498 | 1496 |
1499 void parseAnalyzerOutput(List<String> outErrors, List<String> outWarnings) { | 1497 void parseAnalyzerOutput(List<String> outErrors, List<String> outWarnings) { |
1500 // Parse a line delimited by the | character using \ as an escape character | 1498 // Parse a line delimited by the | character using \ as an escape character |
1501 // like: FOO|BAR|FOO\|BAR|FOO\\BAZ as 4 fields: FOO BAR FOO|BAR FOO\BAZ | 1499 // like: FOO|BAR|FOO\|BAR|FOO\\BAZ as 4 fields: FOO BAR FOO|BAR FOO\BAZ |
1502 List<String> splitMachineError(String line) { | 1500 List<String> splitMachineError(String line) { |
1503 StringBuffer field = new StringBuffer(); | 1501 StringBuffer field = new StringBuffer(); |
1504 List<String> result = []; | 1502 List<String> result = []; |
1505 bool escaped = false; | 1503 bool escaped = false; |
1506 for (var i = 0; i < line.length; i++) { | 1504 for (var i = 0; i < line.length; i++) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1542 static const DART_VM_EXITCODE_DFE_ERROR = 252; | 1540 static const DART_VM_EXITCODE_DFE_ERROR = 252; |
1543 static const DART_VM_EXITCODE_COMPILE_TIME_ERROR = 254; | 1541 static const DART_VM_EXITCODE_COMPILE_TIME_ERROR = 254; |
1544 static const DART_VM_EXITCODE_UNCAUGHT_EXCEPTION = 255; | 1542 static const DART_VM_EXITCODE_UNCAUGHT_EXCEPTION = 255; |
1545 | 1543 |
1546 VmCommandOutputImpl(Command command, int exitCode, bool timedOut, | 1544 VmCommandOutputImpl(Command command, int exitCode, bool timedOut, |
1547 List<int> stdout, List<int> stderr, Duration time, int pid) | 1545 List<int> stdout, List<int> stderr, Duration time, int pid) |
1548 : super(command, exitCode, timedOut, stdout, stderr, time, false, pid); | 1546 : super(command, exitCode, timedOut, stdout, stderr, time, false, pid); |
1549 | 1547 |
1550 Expectation result(TestCase testCase) { | 1548 Expectation result(TestCase testCase) { |
1551 // Handle crashes and timeouts first | 1549 // Handle crashes and timeouts first |
1552 if (exitCode == DART_VM_EXITCODE_DFE_ERROR) return Expectation.dartkCrash; | 1550 if (exitCode == DART_VM_EXITCODE_DFE_ERROR) return Expectation.DARTK_CRASH; |
1553 if (hasCrashed) return Expectation.crash; | 1551 if (hasCrashed) return Expectation.CRASH; |
1554 if (hasTimedOut) return Expectation.timeout; | 1552 if (hasTimedOut) return Expectation.TIMEOUT; |
1555 if (hasNonUtf8) return Expectation.nonUtf8Error; | 1553 if (hasNonUtf8) return Expectation.NON_UTF8_ERROR; |
1556 | 1554 |
1557 // Multitests are handled specially | 1555 // Multitests are handled specially |
1558 if (testCase.expectCompileError) { | 1556 if (testCase.expectCompileError) { |
1559 if (exitCode == DART_VM_EXITCODE_COMPILE_TIME_ERROR) { | 1557 if (exitCode == DART_VM_EXITCODE_COMPILE_TIME_ERROR) { |
1560 return Expectation.pass; | 1558 return Expectation.PASS; |
1561 } | 1559 } |
1562 return Expectation.missingCompileTimeError; | 1560 return Expectation.MISSING_COMPILETIME_ERROR; |
1563 } | 1561 } |
1564 if (testCase.hasRuntimeError) { | 1562 if (testCase.hasRuntimeError) { |
1565 // TODO(kustermann): Do we consider a "runtimeError" only an uncaught | 1563 // TODO(kustermann): Do we consider a "runtimeError" only an uncaught |
1566 // exception or does any nonzero exit code fullfil this requirement? | 1564 // exception or does any nonzero exit code fullfil this requirement? |
1567 if (exitCode != 0) { | 1565 if (exitCode != 0) { |
1568 return Expectation.pass; | 1566 return Expectation.PASS; |
1569 } | 1567 } |
1570 return Expectation.missingRuntimeError; | 1568 return Expectation.MISSING_RUNTIME_ERROR; |
1571 } | 1569 } |
1572 | 1570 |
1573 // The actual outcome depends on the exitCode | 1571 // The actual outcome depends on the exitCode |
1574 Expectation outcome; | 1572 Expectation outcome; |
1575 if (exitCode == DART_VM_EXITCODE_COMPILE_TIME_ERROR) { | 1573 if (exitCode == DART_VM_EXITCODE_COMPILE_TIME_ERROR) { |
1576 outcome = Expectation.compileTimeError; | 1574 outcome = Expectation.COMPILETIME_ERROR; |
1577 } else if (exitCode == DART_VM_EXITCODE_UNCAUGHT_EXCEPTION) { | 1575 } else if (exitCode == DART_VM_EXITCODE_UNCAUGHT_EXCEPTION) { |
1578 outcome = Expectation.runtimeError; | 1576 outcome = Expectation.RUNTIME_ERROR; |
1579 } else if (exitCode != 0) { | 1577 } else if (exitCode != 0) { |
1580 // This is a general fail, in case we get an unknown nonzero exitcode. | 1578 // This is a general fail, in case we get an unknown nonzero exitcode. |
1581 outcome = Expectation.fail; | 1579 outcome = Expectation.FAIL; |
1582 } else { | 1580 } else { |
1583 outcome = Expectation.pass; | 1581 outcome = Expectation.PASS; |
1584 } | 1582 } |
1585 outcome = _negateOutcomeIfIncompleteAsyncTest(outcome, decodeUtf8(stdout)); | 1583 outcome = _negateOutcomeIfIncompleteAsyncTest(outcome, decodeUtf8(stdout)); |
1586 return _negateOutcomeIfNegativeTest(outcome, testCase.isNegative); | 1584 return _negateOutcomeIfNegativeTest(outcome, testCase.isNegative); |
1587 } | 1585 } |
1588 } | 1586 } |
1589 | 1587 |
1590 class CompilationCommandOutputImpl extends CommandOutputImpl { | 1588 class CompilationCommandOutputImpl extends CommandOutputImpl { |
1591 static const DART2JS_EXITCODE_CRASH = 253; | 1589 static const DART2JS_EXITCODE_CRASH = 253; |
1592 | 1590 |
1593 CompilationCommandOutputImpl( | 1591 CompilationCommandOutputImpl( |
1594 Command command, | 1592 Command command, |
1595 int exitCode, | 1593 int exitCode, |
1596 bool timedOut, | 1594 bool timedOut, |
1597 List<int> stdout, | 1595 List<int> stdout, |
1598 List<int> stderr, | 1596 List<int> stderr, |
1599 Duration time, | 1597 Duration time, |
1600 bool compilationSkipped) | 1598 bool compilationSkipped) |
1601 : super(command, exitCode, timedOut, stdout, stderr, time, | 1599 : super(command, exitCode, timedOut, stdout, stderr, time, |
1602 compilationSkipped, 0); | 1600 compilationSkipped, 0); |
1603 | 1601 |
1604 Expectation result(TestCase testCase) { | 1602 Expectation result(TestCase testCase) { |
1605 // Handle general crash/timeout detection. | 1603 // Handle general crash/timeout detection. |
1606 if (hasCrashed) return Expectation.crash; | 1604 if (hasCrashed) return Expectation.CRASH; |
1607 if (hasTimedOut) { | 1605 if (hasTimedOut) { |
1608 bool isWindows = io.Platform.operatingSystem == 'windows'; | 1606 bool isWindows = io.Platform.operatingSystem == 'windows'; |
1609 bool isBrowserTestCase = | 1607 bool isBrowserTestCase = |
1610 testCase.commands.any((command) => command is BrowserTestCommand); | 1608 testCase.commands.any((command) => command is BrowserTestCommand); |
1611 // TODO(26060) Dart2js batch mode hangs on Windows under heavy load. | 1609 // TODO(26060) Dart2js batch mode hangs on Windows under heavy load. |
1612 return (isWindows && isBrowserTestCase) | 1610 return (isWindows && isBrowserTestCase) |
1613 ? Expectation.ignore | 1611 ? Expectation.IGNORE |
1614 : Expectation.timeout; | 1612 : Expectation.TIMEOUT; |
1615 } | 1613 } |
1616 if (hasNonUtf8) return Expectation.nonUtf8Error; | 1614 if (hasNonUtf8) return Expectation.NON_UTF8_ERROR; |
1617 | 1615 |
1618 // Handle dart2js specific crash detection | 1616 // Handle dart2js specific crash detection |
1619 if (exitCode == DART2JS_EXITCODE_CRASH || | 1617 if (exitCode == DART2JS_EXITCODE_CRASH || |
1620 exitCode == VmCommandOutputImpl.DART_VM_EXITCODE_COMPILE_TIME_ERROR || | 1618 exitCode == VmCommandOutputImpl.DART_VM_EXITCODE_COMPILE_TIME_ERROR || |
1621 exitCode == VmCommandOutputImpl.DART_VM_EXITCODE_UNCAUGHT_EXCEPTION) { | 1619 exitCode == VmCommandOutputImpl.DART_VM_EXITCODE_UNCAUGHT_EXCEPTION) { |
1622 return Expectation.crash; | 1620 return Expectation.CRASH; |
1623 } | 1621 } |
1624 | 1622 |
1625 // Multitests are handled specially | 1623 // Multitests are handled specially |
1626 if (testCase.expectCompileError) { | 1624 if (testCase.expectCompileError) { |
1627 // Nonzero exit code of the compiler means compilation failed | 1625 // Nonzero exit code of the compiler means compilation failed |
1628 // TODO(kustermann): Do we have a special exit code in that case??? | 1626 // TODO(kustermann): Do we have a special exit code in that case??? |
1629 if (exitCode != 0) { | 1627 if (exitCode != 0) { |
1630 return Expectation.pass; | 1628 return Expectation.PASS; |
1631 } | 1629 } |
1632 return Expectation.missingCompileTimeError; | 1630 return Expectation.MISSING_COMPILETIME_ERROR; |
1633 } | 1631 } |
1634 | 1632 |
1635 // TODO(kustermann): This is a hack, remove it | 1633 // TODO(kustermann): This is a hack, remove it |
1636 if (testCase.hasRuntimeError && testCase.commands.length > 1) { | 1634 if (testCase.hasRuntimeError && testCase.commands.length > 1) { |
1637 // We expected to run the test, but we got an compile time error. | 1635 // We expected to run the test, but we got an compile time error. |
1638 // If the compilation succeeded, we wouldn't be in here! | 1636 // If the compilation succeeded, we wouldn't be in here! |
1639 assert(exitCode != 0); | 1637 assert(exitCode != 0); |
1640 return Expectation.compileTimeError; | 1638 return Expectation.COMPILETIME_ERROR; |
1641 } | 1639 } |
1642 | 1640 |
1643 Expectation outcome = | 1641 Expectation outcome = |
1644 exitCode == 0 ? Expectation.pass : Expectation.compileTimeError; | 1642 exitCode == 0 ? Expectation.PASS : Expectation.COMPILETIME_ERROR; |
1645 return _negateOutcomeIfNegativeTest(outcome, testCase.isNegative); | 1643 return _negateOutcomeIfNegativeTest(outcome, testCase.isNegative); |
1646 } | 1644 } |
1647 } | 1645 } |
1648 | 1646 |
1649 class KernelCompilationCommandOutputImpl extends CompilationCommandOutputImpl { | 1647 class KernelCompilationCommandOutputImpl extends CompilationCommandOutputImpl { |
1650 KernelCompilationCommandOutputImpl( | 1648 KernelCompilationCommandOutputImpl( |
1651 Command command, | 1649 Command command, |
1652 int exitCode, | 1650 int exitCode, |
1653 bool timedOut, | 1651 bool timedOut, |
1654 List<int> stdout, | 1652 List<int> stdout, |
1655 List<int> stderr, | 1653 List<int> stderr, |
1656 Duration time, | 1654 Duration time, |
1657 bool compilationSkipped) | 1655 bool compilationSkipped) |
1658 : super(command, exitCode, timedOut, stdout, stderr, time, | 1656 : super(command, exitCode, timedOut, stdout, stderr, time, |
1659 compilationSkipped); | 1657 compilationSkipped); |
1660 | 1658 |
1661 bool get canRunDependendCommands { | 1659 bool get canRunDependendCommands { |
1662 // See [BatchRunnerProcess]: 0 means success, 1 means compile-time error. | 1660 // See [BatchRunnerProcess]: 0 means success, 1 means compile-time error. |
1663 // TODO(asgerf): When the frontend supports it, continue running even if | 1661 // TODO(asgerf): When the frontend supports it, continue running even if |
1664 // there were compile-time errors. See kernel_sdk issue #18. | 1662 // there were compile-time errors. See kernel_sdk issue #18. |
1665 return !hasCrashed && !timedOut && exitCode == 0; | 1663 return !hasCrashed && !timedOut && exitCode == 0; |
1666 } | 1664 } |
1667 | 1665 |
1668 Expectation result(TestCase testCase) { | 1666 Expectation result(TestCase testCase) { |
1669 Expectation result = super.result(testCase); | 1667 Expectation result = super.result(testCase); |
1670 if (result.canBeOutcomeOf(Expectation.crash)) { | 1668 if (result.canBeOutcomeOf(Expectation.CRASH)) { |
1671 return Expectation.dartkCrash; | 1669 return Expectation.DARTK_CRASH; |
1672 } else if (result.canBeOutcomeOf(Expectation.timeout)) { | 1670 } else if (result.canBeOutcomeOf(Expectation.TIMEOUT)) { |
1673 return Expectation.dartkTimeout; | 1671 return Expectation.DARTK_TIMEOUT; |
1674 } else if (result.canBeOutcomeOf(Expectation.compileTimeError)) { | 1672 } else if (result.canBeOutcomeOf(Expectation.COMPILETIME_ERROR)) { |
1675 return Expectation.dartkCompileTimeError; | 1673 return Expectation.DARTK_COMPILETIME_ERROR; |
1676 } | 1674 } |
1677 return result; | 1675 return result; |
1678 } | 1676 } |
1679 | 1677 |
1680 // If the compiler was able to produce a Kernel IR file we want to run the | 1678 // If the compiler was able to produce a Kernel IR file we want to run the |
1681 // result on the Dart VM. We therefore mark the [KernelCompilationCommand] as | 1679 // result on the Dart VM. We therefore mark the [KernelCompilationCommand] as |
1682 // successful. | 1680 // successful. |
1683 // => This ensures we test that the DartVM produces correct CompileTime errors | 1681 // => This ensures we test that the DartVM produces correct CompileTime errors |
1684 // as it is supposed to for our test suites. | 1682 // as it is supposed to for our test suites. |
1685 bool get successful => canRunDependendCommands; | 1683 bool get successful => canRunDependendCommands; |
1686 } | 1684 } |
1687 | 1685 |
1688 class JsCommandlineOutputImpl extends CommandOutputImpl | 1686 class JsCommandlineOutputImpl extends CommandOutputImpl |
1689 with UnittestSuiteMessagesMixin { | 1687 with UnittestSuiteMessagesMixin { |
1690 JsCommandlineOutputImpl(Command command, int exitCode, bool timedOut, | 1688 JsCommandlineOutputImpl(Command command, int exitCode, bool timedOut, |
1691 List<int> stdout, List<int> stderr, Duration time) | 1689 List<int> stdout, List<int> stderr, Duration time) |
1692 : super(command, exitCode, timedOut, stdout, stderr, time, false, 0); | 1690 : super(command, exitCode, timedOut, stdout, stderr, time, false, 0); |
1693 | 1691 |
1694 Expectation result(TestCase testCase) { | 1692 Expectation result(TestCase testCase) { |
1695 // Handle crashes and timeouts first | 1693 // Handle crashes and timeouts first |
1696 if (hasCrashed) return Expectation.crash; | 1694 if (hasCrashed) return Expectation.CRASH; |
1697 if (hasTimedOut) return Expectation.timeout; | 1695 if (hasTimedOut) return Expectation.TIMEOUT; |
1698 if (hasNonUtf8) return Expectation.nonUtf8Error; | 1696 if (hasNonUtf8) return Expectation.NON_UTF8_ERROR; |
1699 | 1697 |
1700 if (testCase.hasRuntimeError) { | 1698 if (testCase.hasRuntimeError) { |
1701 if (exitCode != 0) return Expectation.pass; | 1699 if (exitCode != 0) return Expectation.PASS; |
1702 return Expectation.missingRuntimeError; | 1700 return Expectation.MISSING_RUNTIME_ERROR; |
1703 } | 1701 } |
1704 | 1702 |
1705 var outcome = exitCode == 0 ? Expectation.pass : Expectation.runtimeError; | 1703 var outcome = exitCode == 0 ? Expectation.PASS : Expectation.RUNTIME_ERROR; |
1706 outcome = _negateOutcomeIfIncompleteAsyncTest(outcome, decodeUtf8(stdout)); | 1704 outcome = _negateOutcomeIfIncompleteAsyncTest(outcome, decodeUtf8(stdout)); |
1707 return _negateOutcomeIfNegativeTest(outcome, testCase.isNegative); | 1705 return _negateOutcomeIfNegativeTest(outcome, testCase.isNegative); |
1708 } | 1706 } |
1709 } | 1707 } |
1710 | 1708 |
1711 class PubCommandOutputImpl extends CommandOutputImpl { | 1709 class PubCommandOutputImpl extends CommandOutputImpl { |
1712 PubCommandOutputImpl(PubCommand command, int exitCode, bool timedOut, | 1710 PubCommandOutputImpl(PubCommand command, int exitCode, bool timedOut, |
1713 List<int> stdout, List<int> stderr, Duration time) | 1711 List<int> stdout, List<int> stderr, Duration time) |
1714 : super(command, exitCode, timedOut, stdout, stderr, time, false, 0); | 1712 : super(command, exitCode, timedOut, stdout, stderr, time, false, 0); |
1715 | 1713 |
1716 Expectation result(TestCase testCase) { | 1714 Expectation result(TestCase testCase) { |
1717 // Handle crashes and timeouts first | 1715 // Handle crashes and timeouts first |
1718 if (hasCrashed) return Expectation.crash; | 1716 if (hasCrashed) return Expectation.CRASH; |
1719 if (hasTimedOut) return Expectation.timeout; | 1717 if (hasTimedOut) return Expectation.TIMEOUT; |
1720 if (hasNonUtf8) return Expectation.nonUtf8Error; | 1718 if (hasNonUtf8) return Expectation.NON_UTF8_ERROR; |
1721 | 1719 |
1722 if (exitCode == 0) { | 1720 if (exitCode == 0) { |
1723 return Expectation.pass; | 1721 return Expectation.PASS; |
1724 } else if ((command as PubCommand).command == 'get') { | 1722 } else if ((command as PubCommand).command == 'get') { |
1725 return Expectation.pubGetError; | 1723 return Expectation.PUB_GET_ERROR; |
1726 } else { | 1724 } else { |
1727 return Expectation.fail; | 1725 return Expectation.FAIL; |
1728 } | 1726 } |
1729 } | 1727 } |
1730 } | 1728 } |
1731 | 1729 |
1732 class ScriptCommandOutputImpl extends CommandOutputImpl { | 1730 class ScriptCommandOutputImpl extends CommandOutputImpl { |
1733 final Expectation _result; | 1731 final Expectation _result; |
1734 | 1732 |
1735 ScriptCommandOutputImpl(ScriptCommand command, this._result, | 1733 ScriptCommandOutputImpl(ScriptCommand command, this._result, |
1736 String scriptExecutionInformation, Duration time) | 1734 String scriptExecutionInformation, Duration time) |
1737 : super(command, 0, false, [], [], time, false, 0) { | 1735 : super(command, 0, false, [], [], time, false, 0) { |
1738 var lines = scriptExecutionInformation.split("\n"); | 1736 var lines = scriptExecutionInformation.split("\n"); |
1739 diagnostics.addAll(lines); | 1737 diagnostics.addAll(lines); |
1740 } | 1738 } |
1741 | 1739 |
1742 Expectation result(TestCase testCase) => _result; | 1740 Expectation result(TestCase testCase) => _result; |
1743 | 1741 |
1744 bool get canRunDependendCommands => _result == Expectation.pass; | 1742 bool get canRunDependendCommands => _result == Expectation.PASS; |
1745 | 1743 |
1746 bool get successful => _result == Expectation.pass; | 1744 bool get successful => _result == Expectation.PASS; |
1747 } | 1745 } |
1748 | 1746 |
1749 CommandOutput createCommandOutput(Command command, int exitCode, bool timedOut, | 1747 CommandOutput createCommandOutput(Command command, int exitCode, bool timedOut, |
1750 List<int> stdout, List<int> stderr, Duration time, bool compilationSkipped, | 1748 List<int> stdout, List<int> stderr, Duration time, bool compilationSkipped, |
1751 [int pid = 0]) { | 1749 [int pid = 0]) { |
1752 if (command is ContentShellCommand) { | 1750 if (command is ContentShellCommand) { |
1753 return new BrowserCommandOutputImpl( | 1751 return new BrowserCommandOutputImpl( |
1754 command, exitCode, timedOut, stdout, stderr, time, compilationSkipped); | 1752 command, exitCode, timedOut, stdout, stderr, time, compilationSkipped); |
1755 } else if (command is BrowserTestCommand) { | 1753 } else if (command is BrowserTestCommand) { |
1756 return new HTMLBrowserCommandOutputImpl( | 1754 return new HTMLBrowserCommandOutputImpl( |
(...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3291 } | 3289 } |
3292 } | 3290 } |
3293 | 3291 |
3294 void eventAllTestsDone() { | 3292 void eventAllTestsDone() { |
3295 for (var listener in _eventListener) { | 3293 for (var listener in _eventListener) { |
3296 listener.allDone(); | 3294 listener.allDone(); |
3297 } | 3295 } |
3298 _allDone(); | 3296 _allDone(); |
3299 } | 3297 } |
3300 } | 3298 } |
OLD | NEW |