| 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 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 if (allowRetries && testCase.usesWebDriver | 538 if (allowRetries && testCase.usesWebDriver |
| 539 && testCase.output.unexpectedOutput | 539 && testCase.output.unexpectedOutput |
| 540 && testCase.dynamic.numRetries > 0) { | 540 && testCase.dynamic.numRetries > 0) { |
| 541 // Selenium tests can be flaky. Try rerunning. | 541 // Selenium tests can be flaky. Try rerunning. |
| 542 testCase.output.requestRetry = true; | 542 testCase.output.requestRetry = true; |
| 543 } | 543 } |
| 544 if (testCase.output.requestRetry) { | 544 if (testCase.output.requestRetry) { |
| 545 testCase.output.requestRetry = false; | 545 testCase.output.requestRetry = false; |
| 546 this.timedOut = false; | 546 this.timedOut = false; |
| 547 testCase.dynamic.numRetries--; | 547 testCase.dynamic.numRetries--; |
| 548 print("Potential flake. Re-running ${testCase.displayName} " + | 548 print("Potential flake. Re-running ${testCase.displayName} " |
| 549 "(${testCase.dynamic.numRetries} attempt(s) remains)"); | 549 "(${testCase.dynamic.numRetries} attempt(s) remains)"); |
| 550 this.start(); | 550 this.start(); |
| 551 } else { | 551 } else { |
| 552 testCase.completed(); | 552 testCase.completed(); |
| 553 } | 553 } |
| 554 } | 554 } |
| 555 | 555 |
| 556 /** | 556 /** |
| 557 * Process exit handler called at the end of every command. It internally | 557 * Process exit handler called at the end of every command. It internally |
| 558 * treats all but the last command as compilation steps. The last command is | 558 * treats all but the last command as compilation steps. The last command is |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 _stdoutDrained = false; | 719 _stdoutDrained = false; |
| 720 _stderrDrained = false; | 720 _stderrDrained = false; |
| 721 _stdoutStream.onLine = _readStdout(_stdoutStream, _testStdout); | 721 _stdoutStream.onLine = _readStdout(_stdoutStream, _testStdout); |
| 722 _stderrStream.onLine = _readStderr(_stderrStream, _testStderr); | 722 _stderrStream.onLine = _readStderr(_stderrStream, _testStderr); |
| 723 _timer = new Timer(testCase.timeout * 1000, _timeoutHandler); | 723 _timer = new Timer(testCase.timeout * 1000, _timeoutHandler); |
| 724 var line = _createArgumentsLine(testCase.batchTestArguments); | 724 var line = _createArgumentsLine(testCase.batchTestArguments); |
| 725 _process.stdin.write(line.charCodes()); | 725 _process.stdin.write(line.charCodes()); |
| 726 } | 726 } |
| 727 | 727 |
| 728 String _createArgumentsLine(List<String> arguments) { | 728 String _createArgumentsLine(List<String> arguments) { |
| 729 return Strings.join(arguments, ' ') + '\n'; | 729 return Strings.join(arguments, ' ').concat('\n'); |
| 730 } | 730 } |
| 731 | 731 |
| 732 void _testCompleted() { | 732 void _testCompleted() { |
| 733 var test = _currentTest; | 733 var test = _currentTest; |
| 734 _currentTest = null; | 734 _currentTest = null; |
| 735 test.completed(); | 735 test.completed(); |
| 736 } | 736 } |
| 737 | 737 |
| 738 int _reportResult(String output) { | 738 int _reportResult(String output) { |
| 739 _stdoutDrained = true; | 739 _stdoutDrained = true; |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 | 1030 |
| 1031 /** | 1031 /** |
| 1032 * For browser tests using Safari or Opera, we need to use the Selenium 1.0 | 1032 * For browser tests using Safari or Opera, we need to use the Selenium 1.0 |
| 1033 * Java server. | 1033 * Java server. |
| 1034 */ | 1034 */ |
| 1035 void _startSeleniumServer() { | 1035 void _startSeleniumServer() { |
| 1036 // Get the absolute path to the Selenium jar. | 1036 // Get the absolute path to the Selenium jar. |
| 1037 String filePath = new Options().script; | 1037 String filePath = new Options().script; |
| 1038 String pathSep = Platform.pathSeparator; | 1038 String pathSep = Platform.pathSeparator; |
| 1039 int index = filePath.lastIndexOf(pathSep); | 1039 int index = filePath.lastIndexOf(pathSep); |
| 1040 filePath = filePath.substring(0, index) + '${pathSep}testing${pathSep}'; | 1040 filePath = '${filePath.substring(0, index)}${pathSep}testing${pathSep}'; |
| 1041 var lister = new Directory(filePath).list(); | 1041 var lister = new Directory(filePath).list(); |
| 1042 lister.onFile = (String file) { | 1042 lister.onFile = (String file) { |
| 1043 if (const RegExp(@"selenium-server-standalone-.*\.jar").hasMatch(file) | 1043 if (const RegExp(@"selenium-server-standalone-.*\.jar").hasMatch(file) |
| 1044 && _seleniumServer == null) { | 1044 && _seleniumServer == null) { |
| 1045 _seleniumServer = Process.start('java', ['-jar', file]); | 1045 _seleniumServer = Process.start('java', ['-jar', file]); |
| 1046 _seleniumServer.onError = (e) { | 1046 _seleniumServer.onError = (e) { |
| 1047 print("Error starting process:"); | 1047 print("Error starting process:"); |
| 1048 print(" Command: java -jar $file"); | 1048 print(" Command: java -jar $file"); |
| 1049 print(" Error: $e"); | 1049 print(" Error: $e"); |
| 1050 }; | 1050 }; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1088 if (!runner.active) return runner; | 1088 if (!runner.active) return runner; |
| 1089 } | 1089 } |
| 1090 throw new Exception('Unable to find inactive batch runner.'); | 1090 throw new Exception('Unable to find inactive batch runner.'); |
| 1091 } | 1091 } |
| 1092 | 1092 |
| 1093 void _tryRunTest() { | 1093 void _tryRunTest() { |
| 1094 _checkDone(); | 1094 _checkDone(); |
| 1095 if (_numProcesses < _maxProcesses && !_tests.isEmpty()) { | 1095 if (_numProcesses < _maxProcesses && !_tests.isEmpty()) { |
| 1096 TestCase test = _tests.removeFirst(); | 1096 TestCase test = _tests.removeFirst(); |
| 1097 if (_listTests) { | 1097 if (_listTests) { |
| 1098 final String tab = '\t'; | 1098 var fields = [test.displayName, |
| 1099 String outcomes = | 1099 Strings.join(new List.from(test.expectedOutcomes), ','), |
| 1100 Strings.join(new List.from(test.expectedOutcomes), ','); | 1100 test.isNegative]; |
| 1101 print(test.displayName + tab + outcomes + tab + test.isNegative + | 1101 fields.addAll(test.commands.last().arguments); |
| 1102 tab + Strings.join(test.commands.last().arguments, tab)); | 1102 print(Strings.join(fields, '\t')); |
| 1103 return; | 1103 return; |
| 1104 } | 1104 } |
| 1105 if (test.usesWebDriver && _needsSelenium && !_isSeleniumAvailable) { | 1105 if (test.usesWebDriver && _needsSelenium && !_isSeleniumAvailable) { |
| 1106 // The server is not ready to run Selenium tests. Put the test back in | 1106 // The server is not ready to run Selenium tests. Put the test back in |
| 1107 // the queue. Avoid spin-polling by using a timeout. | 1107 // the queue. Avoid spin-polling by using a timeout. |
| 1108 _tests.add(test); | 1108 _tests.add(test); |
| 1109 new Timer(1000, (timer) {_tryRunTest();}); // Don't lose a process. | 1109 new Timer(1000, (timer) {_tryRunTest();}); // Don't lose a process. |
| 1110 return; | 1110 return; |
| 1111 } | 1111 } |
| 1112 if (_verbose) { | 1112 if (_verbose) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1136 // the developer doesn't waste his or her time trying to fix a bunch of | 1136 // the developer doesn't waste his or her time trying to fix a bunch of |
| 1137 // tests that appear to be broken but were actually just flakes that | 1137 // tests that appear to be broken but were actually just flakes that |
| 1138 // didn't get retried because there had already been one failure. | 1138 // didn't get retried because there had already been one failure. |
| 1139 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests; | 1139 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests; |
| 1140 new RunningProcess(test, allowRetry, this).start(); | 1140 new RunningProcess(test, allowRetry, this).start(); |
| 1141 } | 1141 } |
| 1142 _numProcesses++; | 1142 _numProcesses++; |
| 1143 } | 1143 } |
| 1144 } | 1144 } |
| 1145 } | 1145 } |
| OLD | NEW |