| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 * tests have two commands, one to compilate the source and another to execute | 70 * tests have two commands, one to compilate the source and another to execute |
| 71 * it. Some isolate tests might even have three, if they require compiling | 71 * it. Some isolate tests might even have three, if they require compiling |
| 72 * multiple sources that are run in isolation. | 72 * multiple sources that are run in isolation. |
| 73 */ | 73 */ |
| 74 List<Command> commands; | 74 List<Command> commands; |
| 75 | 75 |
| 76 Map configuration; | 76 Map configuration; |
| 77 String displayName; | 77 String displayName; |
| 78 TestOutput output; | 78 TestOutput output; |
| 79 bool isNegative; | 79 bool isNegative; |
| 80 bool usesWebDriver; |
| 80 Set<String> expectedOutcomes; | 81 Set<String> expectedOutcomes; |
| 81 TestCaseEvent completedHandler; | 82 TestCaseEvent completedHandler; |
| 82 TestInformation info; | 83 TestInformation info; |
| 83 | 84 |
| 84 TestCase(this.displayName, | 85 TestCase(this.displayName, |
| 85 this.commands, | 86 this.commands, |
| 86 this.configuration, | 87 this.configuration, |
| 87 this.completedHandler, | 88 this.completedHandler, |
| 88 this.expectedOutcomes, | 89 this.expectedOutcomes, |
| 89 {this.isNegative: false, | 90 {this.isNegative: false, |
| 90 this.info: null}) { | 91 this.info: null, |
| 92 this.usesWebDriver: false}) { |
| 91 if (!isNegative) { | 93 if (!isNegative) { |
| 92 this.isNegative = displayName.contains("negative_test"); | 94 this.isNegative = displayName.contains("negative_test"); |
| 93 } | 95 } |
| 94 | 96 |
| 95 // Special command handling. If a special command is specified | 97 // Special command handling. If a special command is specified |
| 96 // we have to completely rewrite the command that we are using. | 98 // we have to completely rewrite the command that we are using. |
| 97 // We generate a new command-line that is the special command where we | 99 // We generate a new command-line that is the special command where we |
| 98 // replace '@' with the original command executable, and generate | 100 // replace '@' with the original command executable, and generate |
| 99 // a command formed like the following | 101 // a command formed like the following |
| 100 // Let PREFIX be what is before the @. | 102 // Let PREFIX be what is before the @. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 final mode = configuration['mode']; | 160 final mode = configuration['mode']; |
| 159 final arch = configuration['arch']; | 161 final arch = configuration['arch']; |
| 160 final checked = configuration['checked'] ? '-checked' : ''; | 162 final checked = configuration['checked'] ? '-checked' : ''; |
| 161 return "$compiler-$runtime$checked ${mode}_$arch"; | 163 return "$compiler-$runtime$checked ${mode}_$arch"; |
| 162 } | 164 } |
| 163 | 165 |
| 164 List<String> get batchRunnerArguments => ['-batch']; | 166 List<String> get batchRunnerArguments => ['-batch']; |
| 165 List<String> get batchTestArguments => commands.last().arguments; | 167 List<String> get batchTestArguments => commands.last().arguments; |
| 166 | 168 |
| 167 void completed() { completedHandler(this); } | 169 void completed() { completedHandler(this); } |
| 168 | |
| 169 bool get usesWebDriver => Contains( | |
| 170 configuration['runtime'], | |
| 171 const ['chrome', 'dartium', 'ff', 'safari', 'ie', 'opera']); | |
| 172 } | 170 } |
| 173 | 171 |
| 174 | 172 |
| 175 /** | 173 /** |
| 176 * BrowserTestCase has an extra compilation command that is run in a separate | 174 * BrowserTestCase has an extra compilation command that is run in a separate |
| 177 * process, before the regular test is run as in the base class [TestCase]. | 175 * process, before the regular test is run as in the base class [TestCase]. |
| 178 * If the compilation command fails, then the rest of the test is not run. | 176 * If the compilation command fails, then the rest of the test is not run. |
| 179 */ | 177 */ |
| 180 class BrowserTestCase extends TestCase { | 178 class BrowserTestCase extends TestCase { |
| 181 /** | 179 /** |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 if (currentStep == totalSteps) { // done with test command | 612 if (currentStep == totalSteps) { // done with test command |
| 615 testComplete(exitCode, false); | 613 testComplete(exitCode, false); |
| 616 } else if (exitCode != 0) { | 614 } else if (exitCode != 0) { |
| 617 stderr.add('test.dart: Compilation failed$suffix, exit code $exitCode\n'); | 615 stderr.add('test.dart: Compilation failed$suffix, exit code $exitCode\n'); |
| 618 testComplete(exitCode, true); | 616 testComplete(exitCode, true); |
| 619 } else { | 617 } else { |
| 620 stderr.add('test.dart: Compilation finished $suffix\n'); | 618 stderr.add('test.dart: Compilation finished $suffix\n'); |
| 621 stdout.add('test.dart: Compilation finished $suffix\n'); | 619 stdout.add('test.dart: Compilation finished $suffix\n'); |
| 622 if (currentStep == totalSteps - 1 && testCase.usesWebDriver && | 620 if (currentStep == totalSteps - 1 && testCase.usesWebDriver && |
| 623 !testCase.configuration['noBatch']) { | 621 !testCase.configuration['noBatch']) { |
| 624 // Note: processQueue will always be non-null for runtime == ie, ff, | 622 // Note: processQueue will always be non-null for runtime == ie9, ff, |
| 625 // safari, chrome, opera. (It is only null for runtime == vm) | 623 // safari, chrome, opera. (It is only null for runtime == vm) |
| 626 // This RunningProcess object is done, and hands over control to | 624 // This RunningProcess object is done, and hands over control to |
| 627 // BatchRunner.startTest(), which handles reporting, etc. | 625 // BatchRunner.startTest(), which handles reporting, etc. |
| 628 timeoutTimer.cancel(); | 626 timeoutTimer.cancel(); |
| 629 processQueue._getBatchRunner(testCase).startTest(testCase); | 627 processQueue._getBatchRunner(testCase).startTest(testCase); |
| 630 } else { | 628 } else { |
| 631 runCommand(testCase.commands[currentStep++], stepExitHandler); | 629 runCommand(testCase.commands[currentStep++], stepExitHandler); |
| 632 } | 630 } |
| 633 } | 631 } |
| 634 } | 632 } |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1247 // the developer doesn't waste his or her time trying to fix a bunch of | 1245 // the developer doesn't waste his or her time trying to fix a bunch of |
| 1248 // tests that appear to be broken but were actually just flakes that | 1246 // tests that appear to be broken but were actually just flakes that |
| 1249 // didn't get retried because there had already been one failure. | 1247 // didn't get retried because there had already been one failure. |
| 1250 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests; | 1248 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests; |
| 1251 new RunningProcess(test, allowRetry, this).start(); | 1249 new RunningProcess(test, allowRetry, this).start(); |
| 1252 } | 1250 } |
| 1253 _numProcesses++; | 1251 _numProcesses++; |
| 1254 } | 1252 } |
| 1255 } | 1253 } |
| 1256 } | 1254 } |
| OLD | NEW |