| 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 // replace '@' with the original command executable, and generate | 268 // replace '@' with the original command executable, and generate |
| 269 // a command formed like the following | 269 // a command formed like the following |
| 270 // Let PREFIX be what is before the @. | 270 // Let PREFIX be what is before the @. |
| 271 // Let SUFFIX be what is after the @. | 271 // Let SUFFIX be what is after the @. |
| 272 // Let EXECUTABLE be the existing executable of the command. | 272 // Let EXECUTABLE be the existing executable of the command. |
| 273 // Let ARGUMENTS be the existing arguments to the existing executable. | 273 // Let ARGUMENTS be the existing arguments to the existing executable. |
| 274 // The new command will be: | 274 // The new command will be: |
| 275 // PREFIX EXECUTABLE SUFFIX ARGUMENTS | 275 // PREFIX EXECUTABLE SUFFIX ARGUMENTS |
| 276 var specialCommand = configuration['special-command']; | 276 var specialCommand = configuration['special-command']; |
| 277 if (!specialCommand.isEmpty) { | 277 if (!specialCommand.isEmpty) { |
| 278 Expect.isTrue(specialCommand.contains('@'), | 278 if (!specialCommand.contains('@')) { |
| 279 "special-command must contain a '@' char"); | 279 throw new Exception("special-command must contain a '@' char"); |
| 280 } |
| 280 var specialCommandSplit = specialCommand.split('@'); | 281 var specialCommandSplit = specialCommand.split('@'); |
| 281 var prefix = specialCommandSplit[0].trim(); | 282 var prefix = specialCommandSplit[0].trim(); |
| 282 var suffix = specialCommandSplit[1].trim(); | 283 var suffix = specialCommandSplit[1].trim(); |
| 283 List<Command> newCommands = []; | 284 List<Command> newCommands = []; |
| 284 for (Command c in commands) { | 285 for (Command c in commands) { |
| 285 // If we don't have a new prefix we will use the existing executable. | 286 // If we don't have a new prefix we will use the existing executable. |
| 286 var newExecutablePath = c.executable;; | 287 var newExecutablePath = c.executable;; |
| 287 var newArguments = []; | 288 var newArguments = []; |
| 288 | 289 |
| 289 if (prefix.length > 0) { | 290 if (prefix.length > 0) { |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 } | 804 } |
| 804 if (testCase.info != null | 805 if (testCase.info != null |
| 805 && testCase.info.optionsFromFile['isMultitest']) { | 806 && testCase.info.optionsFromFile['isMultitest']) { |
| 806 return _didMultitestFail(errors, staticWarnings); | 807 return _didMultitestFail(errors, staticWarnings); |
| 807 } | 808 } |
| 808 return _didStandardTestFail(errors, staticWarnings); | 809 return _didStandardTestFail(errors, staticWarnings); |
| 809 } | 810 } |
| 810 | 811 |
| 811 bool _didMultitestFail(List errors, List staticWarnings) { | 812 bool _didMultitestFail(List errors, List staticWarnings) { |
| 812 Set<String> outcome = testCase.info.multitestOutcome; | 813 Set<String> outcome = testCase.info.multitestOutcome; |
| 813 Expect.isNotNull(outcome); | 814 if (outcome == null) throw new Exception("outcome must not be null"); |
| 814 if (outcome.contains('compile-time error') && errors.length > 0) { | 815 if (outcome.contains('compile-time error') && errors.length > 0) { |
| 815 return true; | 816 return true; |
| 816 } else if (outcome.contains('static type warning') | 817 } else if (outcome.contains('static type warning') |
| 817 && staticWarnings.length > 0) { | 818 && staticWarnings.length > 0) { |
| 818 return true; | 819 return true; |
| 819 } else if (outcome.isEmpty | 820 } else if (outcome.isEmpty |
| 820 && (errors.length > 0 || staticWarnings.length > 0)) { | 821 && (errors.length > 0 || staticWarnings.length > 0)) { |
| 821 return true; | 822 return true; |
| 822 } | 823 } |
| 823 return false; | 824 return false; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 DateTime startTime; | 937 DateTime startTime; |
| 937 Timer timeoutTimer; | 938 Timer timeoutTimer; |
| 938 List<int> stdout = <int>[]; | 939 List<int> stdout = <int>[]; |
| 939 List<int> stderr = <int>[]; | 940 List<int> stderr = <int>[]; |
| 940 bool compilationSkipped = false; | 941 bool compilationSkipped = false; |
| 941 Completer<CommandOutput> completer; | 942 Completer<CommandOutput> completer; |
| 942 | 943 |
| 943 RunningProcess(TestCase this.testCase, Command this.command); | 944 RunningProcess(TestCase this.testCase, Command this.command); |
| 944 | 945 |
| 945 Future<CommandOutput> start() { | 946 Future<CommandOutput> start() { |
| 946 Expect.isFalse(testCase.expectedOutcomes.contains(SKIP)); | 947 if (testCase.expectedOutcomes.contains(SKIP)) { |
| 948 throw new Exception("testCase.expectedOutcomes must not contain 'SKIP'."); |
| 949 } |
| 947 | 950 |
| 948 completer = new Completer<CommandOutput>(); | 951 completer = new Completer<CommandOutput>(); |
| 949 startTime = new DateTime.now(); | 952 startTime = new DateTime.now(); |
| 950 _runCommand(); | 953 _runCommand(); |
| 951 return completer.future; | 954 return completer.future; |
| 952 } | 955 } |
| 953 | 956 |
| 954 void _runCommand() { | 957 void _runCommand() { |
| 955 command.outputIsUpToDate.then((bool isUpToDate) { | 958 command.outputIsUpToDate.then((bool isUpToDate) { |
| 956 if (isUpToDate) { | 959 if (isUpToDate) { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1048 BatchRunnerProcess(TestCase testCase) { | 1051 BatchRunnerProcess(TestCase testCase) { |
| 1049 _command = testCase.commands.last; | 1052 _command = testCase.commands.last; |
| 1050 _executable = testCase.commands.last.executable; | 1053 _executable = testCase.commands.last.executable; |
| 1051 _batchArguments = testCase.batchRunnerArguments; | 1054 _batchArguments = testCase.batchRunnerArguments; |
| 1052 _isWebDriver = testCase.usesWebDriver; | 1055 _isWebDriver = testCase.usesWebDriver; |
| 1053 } | 1056 } |
| 1054 | 1057 |
| 1055 bool get active => _currentTest != null; | 1058 bool get active => _currentTest != null; |
| 1056 | 1059 |
| 1057 void startTest(TestCase testCase) { | 1060 void startTest(TestCase testCase) { |
| 1058 Expect.isNull(_currentTest); | 1061 if (_currentTest != null) { |
| 1062 throw new Exception("_currentTest must be null."); |
| 1063 } |
| 1059 _currentTest = testCase; | 1064 _currentTest = testCase; |
| 1060 _command = testCase.commands.last; | 1065 _command = testCase.commands.last; |
| 1061 if (_process == null) { | 1066 if (_process == null) { |
| 1062 // Start process if not yet started. | 1067 // Start process if not yet started. |
| 1063 _executable = testCase.commands.last.executable; | 1068 _executable = testCase.commands.last.executable; |
| 1064 _startProcess(() { | 1069 _startProcess(() { |
| 1065 doStartTest(testCase); | 1070 doStartTest(testCase); |
| 1066 }); | 1071 }); |
| 1067 } else if (testCase.commands.last.executable != _executable) { | 1072 } else if (testCase.commands.last.executable != _executable) { |
| 1068 // Restart this runner with the right executable for this test | 1073 // Restart this runner with the right executable for this test |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1645 } else { | 1650 } else { |
| 1646 return false; | 1651 return false; |
| 1647 } | 1652 } |
| 1648 } | 1653 } |
| 1649 | 1654 |
| 1650 Future runNextCommandWithRetries(TestCase testCase, bool allowRetry) { | 1655 Future runNextCommandWithRetries(TestCase testCase, bool allowRetry) { |
| 1651 var completer = new Completer(); | 1656 var completer = new Completer(); |
| 1652 | 1657 |
| 1653 var nextCommandIndex = testCase.commandOutputs.keys.length; | 1658 var nextCommandIndex = testCase.commandOutputs.keys.length; |
| 1654 var numberOfCommands = testCase.commands.length; | 1659 var numberOfCommands = testCase.commands.length; |
| 1655 Expect.isTrue(nextCommandIndex < numberOfCommands); | 1660 if (nextCommandIndex >= numberOfCommands) { |
| 1661 throw new Exception( |
| 1662 "nextCommandIndex must be less than numberOfCommands"); |
| 1663 } |
| 1656 var command = testCase.commands[nextCommandIndex]; | 1664 var command = testCase.commands[nextCommandIndex]; |
| 1657 var isLastCommand = nextCommandIndex == (numberOfCommands - 1); | 1665 var isLastCommand = nextCommandIndex == (numberOfCommands - 1); |
| 1658 | 1666 |
| 1659 void runCommand() { | 1667 void runCommand() { |
| 1660 var runningProcess = new RunningProcess(testCase, command); | 1668 var runningProcess = new RunningProcess(testCase, command); |
| 1661 runningProcess.start().then((CommandOutput commandOutput) { | 1669 runningProcess.start().then((CommandOutput commandOutput) { |
| 1662 if (isLastCommand) { | 1670 if (isLastCommand) { |
| 1663 // NOTE: We need to call commandOutput.unexpectedOutput here. | 1671 // NOTE: We need to call commandOutput.unexpectedOutput here. |
| 1664 // Calling this getter may result in the side-effect, that | 1672 // Calling this getter may result in the side-effect, that |
| 1665 // commandOutput.requestRetry is set to true. | 1673 // commandOutput.requestRetry is set to true. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1718 } | 1726 } |
| 1719 } | 1727 } |
| 1720 | 1728 |
| 1721 void eventAllTestsDone() { | 1729 void eventAllTestsDone() { |
| 1722 for (var listener in _eventListener) { | 1730 for (var listener in _eventListener) { |
| 1723 listener.allDone(); | 1731 listener.allDone(); |
| 1724 } | 1732 } |
| 1725 } | 1733 } |
| 1726 } | 1734 } |
| 1727 | 1735 |
| OLD | NEW |