| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 * [TestCase] this is the output of. | 156 * [TestCase] this is the output of. |
| 157 */ | 157 */ |
| 158 class TestOutput { | 158 class TestOutput { |
| 159 TestCase testCase; | 159 TestCase testCase; |
| 160 int exitCode; | 160 int exitCode; |
| 161 bool timedOut; | 161 bool timedOut; |
| 162 bool failed = false; | 162 bool failed = false; |
| 163 List<String> stdout; | 163 List<String> stdout; |
| 164 List<String> stderr; | 164 List<String> stderr; |
| 165 Duration time; | 165 Duration time; |
| 166 /** | 166 /** |
| 167 * Set to true if we encounter a condition in the output that indicates we | 167 * Set to true if we encounter a condition in the output that indicates we |
| 168 * need to rerun this test. | 168 * need to rerun this test. |
| 169 */ | 169 */ |
| 170 bool requestRetry; | 170 bool requestRetry; |
| 171 | 171 |
| 172 TestOutput(this.testCase, this.exitCode, this.timedOut, this.stdout, | 172 TestOutput(this.testCase, this.exitCode, this.timedOut, this.stdout, |
| 173 this.stderr, this.time) { | 173 this.stderr, this.time) { |
| 174 testCase.output = this; | 174 testCase.output = this; |
| 175 requestRetry = false; | 175 requestRetry = false; |
| 176 } | 176 } |
| 177 | 177 |
| 178 String get result() => | 178 String get result() => |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 void exitHandler(int exitCode) { | 252 void exitHandler(int exitCode) { |
| 253 new TestOutput(testCase, exitCode, timedOut, stdout, | 253 new TestOutput(testCase, exitCode, timedOut, stdout, |
| 254 stderr, new Date.now().difference(startTime)); | 254 stderr, new Date.now().difference(startTime)); |
| 255 process.close(); | 255 process.close(); |
| 256 timeoutTimer.cancel(); | 256 timeoutTimer.cancel(); |
| 257 if (testCase.output.unexpectedOutput && testCase.configuration['verbose']) { | 257 if (testCase.output.unexpectedOutput && testCase.configuration['verbose']) { |
| 258 print(testCase.displayName); | 258 print(testCase.displayName); |
| 259 for (var line in testCase.output.stderr) print(line); | 259 for (var line in testCase.output.stderr) print(line); |
| 260 for (var line in testCase.output.stdout) print(line); | 260 for (var line in testCase.output.stdout) print(line); |
| 261 } | 261 } |
| 262 if (testCase is BrowserTestCase && testCase.output.unexpectedOutput && | 262 if (testCase.configuration['component'] == 'webdriver' && |
| 263 testCase.numRetries > 0) { | 263 testCase.output.unexpectedOutput && testCase.numRetries > 0) { |
| 264 // Selenium tests can be flaky. Try rerunning. | 264 // Selenium tests can be flaky. Try rerunning. |
| 265 testCase.output.requestRetry = true; | 265 testCase.output.requestRetry = true; |
| 266 } | 266 } |
| 267 if (testCase.output.requestRetry) { | 267 if (testCase.output.requestRetry) { |
| 268 testCase.output.requestRetry = false; | 268 testCase.output.requestRetry = false; |
| 269 this.timedOut = false; | 269 this.timedOut = false; |
| 270 testCase.dynamic.numRetries--; | 270 testCase.dynamic.numRetries--; |
| 271 print("Potential flake. Re-running " + testCase.displayName); | 271 print("Potential flake. Re-running " + testCase.displayName); |
| 272 this.start(); | 272 this.start(); |
| 273 } else { | 273 } else { |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 Queue<TestCase> _tests; | 505 Queue<TestCase> _tests; |
| 506 ProgressIndicator _progress; | 506 ProgressIndicator _progress; |
| 507 String _temporaryDirectory; | 507 String _temporaryDirectory; |
| 508 // For dartc batch processing we keep a list of batch processes. | 508 // For dartc batch processing we keep a list of batch processes. |
| 509 List<DartcBatchRunnerProcess> _batchProcesses; | 509 List<DartcBatchRunnerProcess> _batchProcesses; |
| 510 // Cache information about test cases per test suite. For multiple | 510 // Cache information about test cases per test suite. For multiple |
| 511 // configurations there is no need to repeatedly search the file | 511 // configurations there is no need to repeatedly search the file |
| 512 // system, generate tests, and search test files for options. | 512 // system, generate tests, and search test files for options. |
| 513 Map<String, List<TestInformation>> _testCache; | 513 Map<String, List<TestInformation>> _testCache; |
| 514 /** | 514 /** |
| 515 * String indicating the browser used to run the tests. Empty if no browser | 515 * String indicating the browser used to run the tests. Empty if no browser |
| 516 * used. | 516 * used. |
| 517 */ | 517 */ |
| 518 String browserUsed; | 518 String browserUsed; |
| 519 | 519 |
| 520 ProcessQueue(int this._maxProcesses, | 520 ProcessQueue(int this._maxProcesses, |
| 521 String progress, | 521 String progress, |
| 522 Date startTime, | 522 Date startTime, |
| 523 bool printTiming, | 523 bool printTiming, |
| 524 Function this._enqueueMoreWork, | 524 Function this._enqueueMoreWork, |
| 525 [bool this._verbose = false, | 525 [bool this._verbose = false, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 556 throw new Exception( | 556 throw new Exception( |
| 557 'Test suite requires temporary directory. Not supported on Windows.'); | 557 'Test suite requires temporary directory. Not supported on Windows.'); |
| 558 } | 558 } |
| 559 var tempDir = new Directory(''); | 559 var tempDir = new Directory(''); |
| 560 tempDir.createTempSync(); | 560 tempDir.createTempSync(); |
| 561 _temporaryDirectory = tempDir.path; | 561 _temporaryDirectory = tempDir.path; |
| 562 return _temporaryDirectory; | 562 return _temporaryDirectory; |
| 563 } | 563 } |
| 564 | 564 |
| 565 /** | 565 /** |
| 566 * Sometimes Webdriver doesn't close every browser window when it's done | 566 * Sometimes Webdriver doesn't close every browser window when it's done |
| 567 * with a test. At the end of all tests we clear out any neglected processes | 567 * with a test. At the end of all tests we clear out any neglected processes |
| 568 * that are still running. | 568 * that are still running. |
| 569 */ | 569 */ |
| 570 void killZombieBrowsers() { | 570 void killZombieBrowsers() { |
| 571 String chromeName = 'chrome'; | 571 String chromeName = 'chrome'; |
| 572 if (new Platform().operatingSystem() == 'macos') { | 572 if (new Platform().operatingSystem() == 'macos') { |
| 573 chromeName = 'Google\ Chrome'; | 573 chromeName = 'Google\ Chrome'; |
| 574 } | 574 } |
| 575 Map<String, List<String>> processNames = {'ie': ['iexplore'], 'safari': | 575 Map<String, List<String>> processNames = {'ie': ['iexplore'], 'safari': |
| 576 ['Safari'], 'ff': ['firefox'], 'chrome': ['chromedriver', chromeName]}; | 576 ['Safari'], 'ff': ['firefox'], 'chrome': ['chromedriver', chromeName]}; |
| 577 for (String name in processNames[browserUsed]) { | 577 for (String name in processNames[browserUsed]) { |
| 578 Process process = null; | 578 Process process = null; |
| 579 if (new Platform().operatingSystem() == 'windows') { | 579 if (new Platform().operatingSystem() == 'windows') { |
| 580 process = new Process.start( | 580 process = new Process.start( |
| 581 'C:\\Windows\\System32\\taskkill.exe', ['/F', '/IM', name + '.exe', | 581 'C:\\Windows\\System32\\taskkill.exe', ['/F', '/IM', name + '.exe', |
| 582 '/T']); | 582 '/T']); |
| 583 } else { | 583 } else { |
| 584 process = new Process.start('killall', ['-9', name]); | 584 process = new Process.start('killall', ['-9', name]); |
| 585 } | 585 } |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 test.displayName != 'dartc/junit_tests') { | 701 test.displayName != 'dartc/junit_tests') { |
| 702 _ensureDartcBatchRunnersStarted(test.executablePath); | 702 _ensureDartcBatchRunnersStarted(test.executablePath); |
| 703 _getDartcBatchRunnerProcess().startTest(test); | 703 _getDartcBatchRunnerProcess().startTest(test); |
| 704 } else { | 704 } else { |
| 705 new RunningProcess(test).start(); | 705 new RunningProcess(test).start(); |
| 706 } | 706 } |
| 707 _numProcesses++; | 707 _numProcesses++; |
| 708 } | 708 } |
| 709 } | 709 } |
| 710 } | 710 } |
| OLD | NEW |