| 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. |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 * [TestCase] this is the output of. | 155 * [TestCase] this is the output of. |
| 156 */ | 156 */ |
| 157 class TestOutput { | 157 class TestOutput { |
| 158 TestCase testCase; | 158 TestCase testCase; |
| 159 int exitCode; | 159 int exitCode; |
| 160 bool timedOut; | 160 bool timedOut; |
| 161 bool failed = false; | 161 bool failed = false; |
| 162 List<String> stdout; | 162 List<String> stdout; |
| 163 List<String> stderr; | 163 List<String> stderr; |
| 164 Duration time; | 164 Duration time; |
| 165 /** |
| 166 * Set to true if we encounter a condition in the output that indicates we |
| 167 * need to rerun this test. |
| 168 */ |
| 169 bool requestRetry; |
| 165 | 170 |
| 166 TestOutput(this.testCase, this.exitCode, this.timedOut, this.stdout, | 171 TestOutput(this.testCase, this.exitCode, this.timedOut, this.stdout, |
| 167 this.stderr, this.time) { | 172 this.stderr, this.time) { |
| 168 testCase.output = this; | 173 testCase.output = this; |
| 174 requestRetry = false; |
| 169 } | 175 } |
| 170 | 176 |
| 171 String get result() => | 177 String get result() => |
| 172 hasCrashed ? CRASH : (hasTimedOut ? TIMEOUT : (hasFailed ? FAIL : PASS)); | 178 hasCrashed ? CRASH : (hasTimedOut ? TIMEOUT : (hasFailed ? FAIL : PASS)); |
| 173 | 179 |
| 174 bool get unexpectedOutput() => !testCase.expectedOutcomes.contains(result); | 180 bool get unexpectedOutput() => !testCase.expectedOutcomes.contains(result); |
| 175 | 181 |
| 176 bool get hasCrashed() { | 182 bool get hasCrashed() { |
| 177 if (new Platform().operatingSystem() == 'windows') { | 183 if (new Platform().operatingSystem() == 'windows') { |
| 178 // The VM uses std::abort to terminate on asserts. | 184 // The VM uses std::abort to terminate on asserts. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 202 } | 208 } |
| 203 previous_line = line; | 209 previous_line = line; |
| 204 } | 210 } |
| 205 | 211 |
| 206 // If the browser test failed, it may have been because DumpRenderTree | 212 // If the browser test failed, it may have been because DumpRenderTree |
| 207 // and the virtual framebuffer X server didn't hook up. | 213 // and the virtual framebuffer X server didn't hook up. |
| 208 for (String line in stderr) { | 214 for (String line in stderr) { |
| 209 if (line.contains('Gtk-WARNING **: cannot open display: :99')) { | 215 if (line.contains('Gtk-WARNING **: cannot open display: :99')) { |
| 210 // If we get the X server error, return the expected value | 216 // If we get the X server error, return the expected value |
| 211 // We cannot restart the test from here. Issue dart:1135 is filed. | 217 // We cannot restart the test from here. Issue dart:1135 is filed. |
| 212 return testCase.isNegative; | 218 requestRetry = true; |
| 219 return true; |
| 213 } | 220 } |
| 214 } | 221 } |
| 215 return true; | 222 return true; |
| 216 } | 223 } |
| 217 | 224 |
| 218 // Reverse result of a negative test. | 225 // Reverse result of a negative test. |
| 219 bool get hasFailed() => (testCase.isNegative ? !didFail : didFail); | 226 bool get hasFailed() => (testCase.isNegative ? !didFail : didFail); |
| 220 } | 227 } |
| 221 | 228 |
| 222 /** | 229 /** |
| (...skipping 17 matching lines...) Expand all Loading... |
| 240 List<Function> handlers; | 247 List<Function> handlers; |
| 241 | 248 |
| 242 RunningProcess(TestCase this.testCase); | 249 RunningProcess(TestCase this.testCase); |
| 243 | 250 |
| 244 void exitHandler(int exitCode) { | 251 void exitHandler(int exitCode) { |
| 245 new TestOutput(testCase, exitCode, timedOut, stdout, | 252 new TestOutput(testCase, exitCode, timedOut, stdout, |
| 246 stderr, new Date.now().difference(startTime)); | 253 stderr, new Date.now().difference(startTime)); |
| 247 process.close(); | 254 process.close(); |
| 248 timeoutTimer.cancel(); | 255 timeoutTimer.cancel(); |
| 249 if (testCase.output.unexpectedOutput && testCase.configuration['verbose']) { | 256 if (testCase.output.unexpectedOutput && testCase.configuration['verbose']) { |
| 250 print(testCase.output.stdout); | 257 print(testCase.displayName); |
| 251 print(testCase.output.stderr); | 258 for (var line in testCase.output.stderr) { |
| 259 print(line); |
| 260 } |
| 261 for (var line in testCase.output.stdout) { |
| 262 print(line); |
| 263 } |
| 252 } | 264 } |
| 253 if (testCase is BrowserTestCase && testCase.output.unexpectedOutput && | 265 if (testCase is BrowserTestCase && testCase.output.unexpectedOutput && |
| 254 !testCase.isRerun) { | 266 !testCase.isRerun) { |
| 255 // Selenium tests can be flaky. Try rerunning. | 267 // Selenium tests can be flaky. Try rerunning. |
| 268 testCase.output.requestRetry = true; |
| 269 } |
| 270 if (testCase.output.requestRetry) { |
| 271 testCase.output.requestRetry = false; |
| 272 this.timedOut = false; |
| 256 testCase.isRerun = true; | 273 testCase.isRerun = true; |
| 257 this.timedOut = false; | 274 print("Potential flake. Re-running " + testCase.displayName); |
| 258 this.start(); | 275 this.start(); |
| 259 } else { | 276 } else { |
| 260 testCase.completed(); | 277 testCase.completed(); |
| 261 } | 278 } |
| 262 } | 279 } |
| 263 | 280 |
| 264 void compilerExitHandler(int exitCode) { | 281 void compilerExitHandler(int exitCode) { |
| 265 if (exitCode != 0) { | 282 if (exitCode != 0) { |
| 266 stderr.add('test.dart: Compilation step failed (exit code $exitCode)\n'); | 283 stderr.add('test.dart: Compilation step failed (exit code $exitCode)\n'); |
| 267 exitHandler(exitCode); | 284 exitHandler(exitCode); |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 test.displayName != 'dartc/junit_tests') { | 646 test.displayName != 'dartc/junit_tests') { |
| 630 _ensureDartcBatchRunnersStarted(test.executablePath); | 647 _ensureDartcBatchRunnersStarted(test.executablePath); |
| 631 _getDartcBatchRunnerProcess().startTest(test); | 648 _getDartcBatchRunnerProcess().startTest(test); |
| 632 } else { | 649 } else { |
| 633 new RunningProcess(test).start(); | 650 new RunningProcess(test).start(); |
| 634 } | 651 } |
| 635 _numProcesses++; | 652 _numProcesses++; |
| 636 } | 653 } |
| 637 } | 654 } |
| 638 } | 655 } |
| OLD | NEW |