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 #import("status_file_parser.dart"); | 7 #import("status_file_parser.dart"); |
| 8 #import("test_progress.dart"); | 8 #import("test_progress.dart"); |
| 9 #import("test_suite.dart"); | 9 #import("test_suite.dart"); |
| 10 | 10 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 for (int i = 1; i < prefixSplit.length; i++) { | 61 for (int i = 1; i < prefixSplit.length; i++) { |
| 62 var current = prefixSplit[i]; | 62 var current = prefixSplit[i]; |
| 63 if (!current.isEmpty()) newArguments.add(current); | 63 if (!current.isEmpty()) newArguments.add(current); |
| 64 } | 64 } |
| 65 newArguments.add(executablePath); | 65 newArguments.add(executablePath); |
| 66 executablePath = newExecutablePath; | 66 executablePath = newExecutablePath; |
| 67 } | 67 } |
| 68 newArguments.addAll(arguments); | 68 newArguments.addAll(arguments); |
| 69 var suffixSplit = prefix.split(' '); | 69 var suffixSplit = prefix.split(' '); |
| 70 suffixSplit.forEach((e) { | 70 suffixSplit.forEach((e) { |
| 71 if (!e.isEmpty()) newArguments.add(e); | 71 if (!e.isEmpty()) newArguments.add(e); |
|
Mads Ager (google)
2011/12/09 09:21:12
Please undo. Two-space indent plese.
| |
| 72 }); | 72 }); |
| 73 arguments = newArguments; | 73 arguments = newArguments; |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 | 76 |
| 77 int get timeout() => configuration['timeout']; | 77 int get timeout() => configuration['timeout']; |
| 78 | 78 |
| 79 void completed() { completedHandler(this); } | 79 void completed() { completedHandler(this); } |
| 80 } | 80 } |
| 81 | 81 |
| 82 | 82 |
| 83 class CompilingTestCase extends TestCase { | |
|
Mads Ager (google)
2011/12/09 09:21:12
Should we call this a BrowserTestCase instead? Whe
| |
| 84 String compilerPath; | |
| 85 List<String> compilerArguments; | |
| 86 | |
| 87 CompilingTestCase(displayName, | |
| 88 this.compilerPath, | |
| 89 this.compilerArguments, | |
| 90 executablePath, | |
| 91 arguments, | |
| 92 configuration, | |
| 93 completedHandler, | |
| 94 expectedOutcomes, | |
| 95 [isNegative = false]) : super(displayName, | |
| 96 executablePath, | |
| 97 arguments, | |
| 98 configuration, | |
| 99 completedHandler, | |
| 100 expectedOutcomes, | |
| 101 isNegative); | |
| 102 // RunningProcess.start() handles CompilingTestCase specially, executing | |
|
Mads Ager (google)
2011/12/09 09:21:12
Could you put this comment on the class level inst
| |
| 103 // the compilation command line first. | |
| 104 } | |
| 105 | |
| 106 | |
| 107 | |
| 83 class TestOutput { | 108 class TestOutput { |
| 84 // The TestCase this is the output from. | 109 // The TestCase this is the output from. |
| 85 TestCase testCase; | 110 TestCase testCase; |
| 86 int exitCode; | 111 int exitCode; |
| 87 bool timedOut; | 112 bool timedOut; |
| 88 bool failed = false; | 113 bool failed = false; |
| 89 List<String> stdout; | 114 List<String> stdout; |
| 90 List<String> stderr; | 115 List<String> stderr; |
| 91 Duration time; | 116 Duration time; |
| 92 | 117 |
| 93 TestOutput(this.testCase, this.exitCode, this.timedOut, this.stdout, | 118 TestOutput(this.testCase, this.exitCode, this.timedOut, this.stdout, |
| 94 this.stderr, this.time) { | 119 this.stderr, this.time) { |
| 95 testCase.output = this; | 120 testCase.output = this; |
| 96 } | 121 } |
| 97 | 122 |
| 98 String get result() => | 123 String get result() => |
| 99 hasCrashed ? CRASH : (hasTimedOut ? TIMEOUT : (hasFailed ? FAIL : PASS)); | 124 hasCrashed ? CRASH : (hasTimedOut ? TIMEOUT : (hasFailed ? FAIL : PASS)); |
| 100 | 125 |
| 101 bool get unexpectedOutput() => !testCase.expectedOutcomes.contains(result); | 126 bool get unexpectedOutput() => !testCase.expectedOutcomes.contains(result); |
| 102 | 127 |
| 103 // The Java dartc runner exits with code 253 in case of unhandles | 128 // The Java dartc runner exits with code 253 in case of unhandled |
| 104 // exceptions. | 129 // exceptions. |
| 105 // The VM uses std::abort to terminate on asserts. | 130 // The VM uses std::abort to terminate on asserts. |
| 106 // std::abort terminates with exit code 3 on Windows. | 131 // std::abort terminates with exit code 3 on Windows. |
| 107 bool get hasCrashed() { | 132 bool get hasCrashed() { |
| 108 if (new Platform().operatingSystem() == 'windows') { | 133 if (new Platform().operatingSystem() == 'windows') { |
| 109 if (exitCode == 3) { | 134 if (exitCode == 3) { |
| 110 return !timedOut; | 135 return !timedOut; |
| 111 } | 136 } |
| 112 return (!timedOut && | 137 return (!timedOut && |
| 113 (exitCode != -1) && | 138 (exitCode != -1) && |
| 114 (exitCode < 0) && | 139 (exitCode < 0) && |
| 115 ((0x3FFFFF00 & exitCode) == 0)); | 140 ((0x3FFFFF00 & exitCode) == 0)); |
| 116 } | 141 } |
| 117 return (!timedOut && | 142 return (!timedOut && |
| 118 (exitCode != -1) && | 143 (exitCode != -1) && |
| 119 ((exitCode < 0) || (exitCode == 253))); | 144 ((exitCode < 0) || (exitCode == 253))); |
| 120 } | 145 } |
| 121 | 146 |
| 122 bool get hasTimedOut() => timedOut; | 147 bool get hasTimedOut() => timedOut; |
| 123 | 148 |
| 124 bool get didFail() => exitCode != 0 && !hasCrashed; | 149 bool get didFail() { |
| 150 if (exitCode != 0 && !hasCrashed) return true; | |
| 151 | |
| 152 if (testCase is !CompilingTestCase) return false; | |
| 153 // Browser tests fail unless stdout contains | |
|
Mads Ager (google)
2011/12/09 09:21:12
I would add a blank line before this comment.
Bill Hesse
2011/12/09 12:33:29
Done.
| |
| 154 // 'Content-Type: text/plain\nPASS'. | |
| 155 String previous_line = ''; | |
| 156 for (String line in stdout) { | |
| 157 if (line == 'PASS' && previous_line == 'Content-Type: text/plain') { | |
| 158 return false; | |
| 159 } | |
| 160 previous_line = line; | |
| 161 } | |
| 162 return true; | |
| 163 } | |
| 125 | 164 |
| 126 // Reverse result of a negative test. | 165 // Reverse result of a negative test. |
| 127 bool get hasFailed() => (testCase.isNegative ? !didFail : didFail); | 166 bool get hasFailed() => (testCase.isNegative ? !didFail : didFail); |
| 128 } | 167 } |
| 129 | 168 |
| 130 | 169 |
| 131 class RunningProcess { | 170 class RunningProcess { |
| 132 Process process; | 171 Process process; |
| 133 TestCase testCase; | 172 TestCase testCase; |
| 134 bool timedOut = false; | 173 bool timedOut = false; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 154 var line = source.readLine(); | 193 var line = source.readLine(); |
| 155 while (null != line) { | 194 while (null != line) { |
| 156 destination.add(line); | 195 destination.add(line); |
| 157 line = source.readLine(); | 196 line = source.readLine(); |
| 158 } | 197 } |
| 159 }; | 198 }; |
| 160 } | 199 } |
| 161 | 200 |
| 162 void start() { | 201 void start() { |
| 163 Expect.isFalse(testCase.expectedOutcomes.contains(SKIP)); | 202 Expect.isFalse(testCase.expectedOutcomes.contains(SKIP)); |
| 164 process = new Process(testCase.executablePath, testCase.arguments); | 203 stdout = new List<String>(); |
| 204 stderr = new List<String>(); | |
| 205 if (testCase is CompilingTestCase) { | |
| 206 | |
|
Mads Ager (google)
2011/12/09 09:21:12
?
Bill Hesse
2011/12/09 12:33:29
Implementation added.
On 2011/12/09 09:21:12, Mad
| |
| 207 } | |
| 208 runCommand(testCase.executablePath, testCase.arguments, exitHandler); | |
| 209 } | |
| 210 | |
| 211 void runCommand(String executable, | |
| 212 List<String> arguments, | |
| 213 Function exitHandler(int exitCode)) { | |
| 214 process = new Process(executable, arguments); | |
| 165 process.exitHandler = exitHandler; | 215 process.exitHandler = exitHandler; |
| 166 startTime = new Date.now(); | 216 startTime = new Date.now(); |
| 167 process.start(); | 217 process.start(); |
| 168 | |
| 169 InputStream stdoutStream = process.stdout; | 218 InputStream stdoutStream = process.stdout; |
| 170 InputStream stderrStream = process.stderr; | 219 InputStream stderrStream = process.stderr; |
| 171 stdout = new List<String>(); | |
| 172 stderr = new List<String>(); | |
| 173 StringInputStream stdoutStringStream = new StringInputStream(stdoutStream); | 220 StringInputStream stdoutStringStream = new StringInputStream(stdoutStream); |
| 174 StringInputStream stderrStringStream = new StringInputStream(stderrStream); | 221 StringInputStream stderrStringStream = new StringInputStream(stderrStream); |
| 175 stdoutStringStream.dataHandler = | 222 stdoutStringStream.dataHandler = |
| 176 makeReadHandler(stdoutStringStream, stdout); | 223 makeReadHandler(stdoutStringStream, stdout); |
| 177 stderrStringStream.dataHandler = | 224 stderrStringStream.dataHandler = |
| 178 makeReadHandler(stderrStringStream, stderr); | 225 makeReadHandler(stderrStringStream, stderr); |
| 179 timeoutTimer = new Timer(timeoutHandler, 1000 * testCase.timeout, false); | 226 timeoutTimer = new Timer(timeoutHandler, 1000 * testCase.timeout, false); |
| 180 } | 227 } |
| 181 | 228 |
| 229 | |
| 230 | |
| 182 void timeoutHandler(Timer unusedTimer) { | 231 void timeoutHandler(Timer unusedTimer) { |
| 183 timedOut = true; | 232 timedOut = true; |
| 184 process.kill(); | 233 process.kill(); |
| 185 } | 234 } |
| 186 } | 235 } |
| 187 | 236 |
| 188 | 237 |
| 189 class DartcBatchRunnerProcess { | 238 class DartcBatchRunnerProcess { |
| 190 String _executable; | 239 String _executable; |
| 191 | 240 |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 407 if (test.configuration['component'] == 'dartc') { | 456 if (test.configuration['component'] == 'dartc') { |
| 408 _ensureDartcBatchRunnersStarted(test.executablePath); | 457 _ensureDartcBatchRunnersStarted(test.executablePath); |
| 409 _getDartcBatchRunnerProcess().startTest(test); | 458 _getDartcBatchRunnerProcess().startTest(test); |
| 410 } else { | 459 } else { |
| 411 new RunningProcess(test).start(); | 460 new RunningProcess(test).start(); |
| 412 } | 461 } |
| 413 _numProcesses++; | 462 _numProcesses++; |
| 414 } | 463 } |
| 415 } | 464 } |
| 416 } | 465 } |
| OLD | NEW |