Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 #library("test_runner"); | 5 #library("test_runner"); |
| 6 | 6 |
| 7 | 7 |
| 8 #import("status_file_parser.dart"); | 8 #import("status_file_parser.dart"); |
| 9 | 9 |
| 10 /** | 10 /** |
| 11 * Classes and methods for executing tests. | 11 * Classes and methods for executing tests. |
| 12 * | 12 * |
| 13 * This module includes: | 13 * This module includes: |
| 14 * - Managing parallel execution of tests, including timeout checks. | 14 * - Managing parallel execution of tests, including timeout checks. |
| 15 * - Evaluating the output of each test as pass/fail/crash/timeout. | 15 * - Evaluating the output of each test as pass/fail/crash/timeout. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 // Possible outcomes of running a test. | |
| 19 final CRASH = "Crash"; | |
| 20 final TIMEOUT = "Timeout"; | |
| 21 final FAIL = "Fail"; | |
| 22 final PASS = "Pass"; | |
| 23 // An indication to skip the test. The caller is responsible for skipping it. | |
| 24 final SKIP = "Skip"; | |
| 25 | |
| 26 final int NO_TIMEOUT = 0; | 18 final int NO_TIMEOUT = 0; |
| 27 | 19 |
| 28 String getDartShellFileName() { | 20 String getDartShellFileName() { |
| 29 var names = ["out/Debug_ia32/dart_bin", | 21 var names = ["out/Debug_ia32/dart_bin", |
| 30 "out/Release_ia32/dart_bin", | 22 "out/Release_ia32/dart_bin", |
| 31 "xcodebuild/Debug_ia32/dart_bin", | 23 "xcodebuild/Debug_ia32/dart_bin", |
| 32 "xcodebuild/Release_ia32/dart_bin", | 24 "xcodebuild/Release_ia32/dart_bin", |
| 33 "Debug_ia32/dart_bin.exe", | 25 "Debug_ia32/dart_bin.exe", |
| 34 "Release_ia32/dart_bin.exe"]; | 26 "Release_ia32/dart_bin.exe"]; |
| 35 for (var name in names) { | 27 for (var name in names) { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 51 Function completedHandler; | 43 Function completedHandler; |
| 52 | 44 |
| 53 TestCase(this.displayName, this.executablePath, this.arguments, | 45 TestCase(this.displayName, this.executablePath, this.arguments, |
| 54 this.completedHandler, this.expectedOutcomes) { | 46 this.completedHandler, this.expectedOutcomes) { |
| 55 commandLine = executablePath; | 47 commandLine = executablePath; |
| 56 for (var arg in arguments) { | 48 for (var arg in arguments) { |
| 57 commandLine += " " + arg; | 49 commandLine += " " + arg; |
| 58 } | 50 } |
| 59 } | 51 } |
| 60 | 52 |
| 61 bool get isNegative() => false; | 53 bool get isNegative() => displayName.contains("NegativeTest"); |
| 62 | 54 |
| 63 void completed() { completedHandler(this); } | 55 void completed() { completedHandler(this); } |
| 64 } | 56 } |
| 65 | 57 |
| 66 | 58 |
| 67 class TestOutput { | 59 class TestOutput { |
| 68 // The TestCase this is the output from. | 60 // The TestCase this is the output from. |
| 69 TestCase testCase; | 61 TestCase testCase; |
| 70 int exitCode; | 62 int exitCode; |
| 71 bool timedOut; | 63 bool timedOut; |
| 72 bool failed = false; | 64 bool failed = false; |
| 73 List<String> stdout; | 65 List<String> stdout; |
| 74 List<String> stderr; | 66 List<String> stderr; |
| 75 Duration time; | 67 Duration time; |
| 76 | 68 |
| 77 TestOutput(this.testCase, this.exitCode, this.timedOut, this.stdout, | 69 TestOutput(this.testCase, this.exitCode, this.timedOut, this.stdout, |
| 78 this.stderr, this.time) { | 70 this.stderr, this.time) { |
| 79 testCase.output = this; | 71 testCase.output = this; |
| 80 } | 72 } |
| 81 | 73 |
| 82 String get result() => | 74 String get result() => |
| 83 hasCrashed ? CRASH : (hasTimedOut ? TIMEOUT : (hasFailed ? FAIL : PASS)); | 75 hasCrashed ? CRASH : (hasTimedOut ? TIMEOUT : (hasFailed ? FAIL : PASS)); |
| 84 | 76 |
| 85 bool get unexpectedOutput() => !testCase.expectedOutcomes.contains(result); | 77 bool get unexpectedOutput() => !testCase.expectedOutcomes.contains(result); |
| 86 | 78 |
| 87 bool get hasCrashed() => !timedOut && exitCode != -1 && exitCode != 0; | 79 bool get hasCrashed() => !timedOut && exitCode != 255 && exitCode != 0; |
|
Mads Ager (google)
2011/11/10 16:31:57
This looks accidental?
Bill Hesse
2011/11/10 16:44:45
No, the processes are returning 255 for uncaught e
Bill Hesse
2011/11/14 10:08:05
OK, this has been fixed, so failures return -1, so
| |
| 88 | 80 |
| 89 bool get hasTimedOut() => timedOut; | 81 bool get hasTimedOut() => timedOut; |
| 90 | 82 |
| 91 bool get didFail() => exitCode != 0 && !hasCrashed; | 83 bool get didFail() => exitCode != 0 && !hasCrashed; |
| 92 | 84 |
| 93 // Reverse result of a negative test. | 85 // Reverse result of a negative test. |
| 94 bool get hasFailed() => (testCase.isNegative ? !didFail : didFail); | 86 bool get hasFailed() => (testCase.isNegative ? !didFail : didFail); |
| 95 } | 87 } |
| 96 | 88 |
| 97 | 89 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 new RunningProcess(test, 60).start(); | 174 new RunningProcess(test, 60).start(); |
| 183 numProcesses++; | 175 numProcesses++; |
| 184 } | 176 } |
| 185 } | 177 } |
| 186 | 178 |
| 187 runTest(TestCase test) { | 179 runTest(TestCase test) { |
| 188 tests.add(test); | 180 tests.add(test); |
| 189 tryRunTest(); | 181 tryRunTest(); |
| 190 } | 182 } |
| 191 } | 183 } |
| OLD | NEW |