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