Chromium Code Reviews| 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 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 740 _startProcess(() { | 740 _startProcess(() { |
| 741 doStartTest(testCase); | 741 doStartTest(testCase); |
| 742 }); | 742 }); |
| 743 }; | 743 }; |
| 744 _process.kill(); | 744 _process.kill(); |
| 745 } else { | 745 } else { |
| 746 doStartTest(testCase); | 746 doStartTest(testCase); |
| 747 } | 747 } |
| 748 } | 748 } |
| 749 | 749 |
| 750 void terminate() { | 750 Future terminate() { |
| 751 if (_process !== null) { | 751 if (_process == null) return new Future.immediate(true); |
| 752 bool closed = false; | 752 Completer completer = new Completer(); |
| 753 _process.onExit = (exitCode) { | 753 _process.onExit = (exitCode) { |
| 754 closed = true; | 754 _process.close(); |
| 755 _process.close(); | 755 completer.complete(true); |
| 756 }; | 756 }; |
| 757 if (_isWebDriver) { | 757 _process.kill(); |
|
Emily Fortuna
2012/10/06 00:11:55
DBC -- why are no longer doing this graceful shutd
Mads Ager (google)
2012/10/06 06:24:09
Because the TODO has been fixed and a kill sends t
| |
| 758 // Use a graceful shutdown so our Selenium script can close | 758 return completer.future; |
| 759 // the open browser processes. TODO(jmesserly): Send a signal once | |
| 760 // that's supported, see dartbug.com/1756. | |
| 761 _process.stdin.write('--terminate\n'.charCodes()); | |
| 762 | |
| 763 // In case the run_selenium process didn't close, kill it after 30s | |
| 764 int shutdownMillisecs = 30000; | |
| 765 new Timer(shutdownMillisecs, (e) { if (!closed) _process.kill(); }); | |
| 766 } else { | |
| 767 _process.kill(); | |
| 768 } | |
| 769 } | |
| 770 } | 759 } |
| 771 | 760 |
| 772 void doStartTest(TestCase testCase) { | 761 void doStartTest(TestCase testCase) { |
| 773 _startTime = new Date.now(); | 762 _startTime = new Date.now(); |
| 774 _testStdout = []; | 763 _testStdout = []; |
| 775 _testStderr = []; | 764 _testStderr = []; |
| 776 _status = null; | 765 _status = null; |
| 777 _stdoutDrained = false; | 766 _stdoutDrained = false; |
| 778 _stderrDrained = false; | 767 _stderrDrained = false; |
| 779 _ignoreStreams = new MutableValue<bool>(false); // Captured by closures. | 768 _ignoreStreams = new MutableValue<bool>(false); // Captured by closures. |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1014 void _testListerDone() { | 1003 void _testListerDone() { |
| 1015 _activeTestListers--; | 1004 _activeTestListers--; |
| 1016 _checkDone(); | 1005 _checkDone(); |
| 1017 } | 1006 } |
| 1018 | 1007 |
| 1019 /** | 1008 /** |
| 1020 * Perform any cleanup needed once all tests in a TestSuite have completed | 1009 * Perform any cleanup needed once all tests in a TestSuite have completed |
| 1021 * and notify our progress indicator that we are done. | 1010 * and notify our progress indicator that we are done. |
| 1022 */ | 1011 */ |
| 1023 void _cleanupAndMarkDone() { | 1012 void _cleanupAndMarkDone() { |
| 1024 // _progress.allDone() exits the process, so we have to call the | |
| 1025 // _allDone callback before. | |
| 1026 _allDone(); | 1013 _allDone(); |
| 1027 if (browserUsed != '' && _seleniumServer != null) { | 1014 if (browserUsed != '' && _seleniumServer != null) { |
| 1028 _seleniumServer.kill(); | 1015 _seleniumServer.kill(); |
| 1029 } else { | 1016 } else { |
| 1030 _progress.allDone(); | 1017 _progress.allDone(); |
| 1031 } | 1018 } |
| 1032 } | 1019 } |
| 1033 | 1020 |
| 1034 void _checkDone() { | 1021 void _checkDone() { |
| 1035 // When there are no more active test listers ask for more work | 1022 // When there are no more active test listers ask for more work |
| 1036 // from process queue users. | 1023 // from process queue users. |
| 1037 if (_activeTestListers == 0) { | 1024 if (_activeTestListers == 0) { |
| 1038 _enqueueMoreWork(this); | 1025 _enqueueMoreWork(this); |
| 1039 } | 1026 } |
| 1040 // If there is still no work, we are done. | 1027 // If there is still no work, we are done. |
| 1041 if (_activeTestListers == 0) { | 1028 if (_activeTestListers == 0) { |
| 1042 _progress.allTestsKnown(); | 1029 _progress.allTestsKnown(); |
| 1043 if (_tests.isEmpty() && _numProcesses == 0) { | 1030 if (_tests.isEmpty() && _numProcesses == 0) { |
| 1044 _terminateBatchRunners(); | 1031 _terminateBatchRunners().then((_) => _cleanupAndMarkDone()); |
| 1045 _cleanupAndMarkDone(); | |
| 1046 } | 1032 } |
| 1047 } | 1033 } |
| 1048 } | 1034 } |
| 1049 | 1035 |
| 1050 /** | 1036 /** |
| 1051 * True if we are using a browser + platform combination that needs the | 1037 * True if we are using a browser + platform combination that needs the |
| 1052 * Selenium server jar. | 1038 * Selenium server jar. |
| 1053 */ | 1039 */ |
| 1054 bool get _needsSelenium => Platform.operatingSystem == 'macos' && | 1040 bool get _needsSelenium => Platform.operatingSystem == 'macos' && |
| 1055 browserUsed == 'safari'; | 1041 browserUsed == 'safari'; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1166 StringInputStream stderrStringStream = | 1152 StringInputStream stderrStringStream = |
| 1167 new StringInputStream(_seleniumServer.stderr); | 1153 new StringInputStream(_seleniumServer.stderr); |
| 1168 stdoutStringStream.onLine = | 1154 stdoutStringStream.onLine = |
| 1169 makeSeleniumServerHandler(stdoutStringStream); | 1155 makeSeleniumServerHandler(stdoutStringStream); |
| 1170 stderrStringStream.onLine = | 1156 stderrStringStream.onLine = |
| 1171 makeSeleniumServerHandler(stderrStringStream); | 1157 makeSeleniumServerHandler(stderrStringStream); |
| 1172 } | 1158 } |
| 1173 }; | 1159 }; |
| 1174 } | 1160 } |
| 1175 | 1161 |
| 1176 void _terminateBatchRunners() { | 1162 Future _terminateBatchRunners() { |
| 1163 var futures = new List(); | |
| 1177 for (var runners in _batchProcesses.getValues()) { | 1164 for (var runners in _batchProcesses.getValues()) { |
| 1178 for (var runner in runners) { | 1165 for (var runner in runners) { |
| 1179 runner.terminate(); | 1166 futures.add(runner.terminate()); |
| 1180 } | 1167 } |
| 1181 } | 1168 } |
| 1169 return Futures.wait(futures); | |
| 1182 } | 1170 } |
| 1183 | 1171 |
| 1184 BatchRunnerProcess _getBatchRunner(TestCase test) { | 1172 BatchRunnerProcess _getBatchRunner(TestCase test) { |
| 1185 // Start batch processes if needed | 1173 // Start batch processes if needed |
| 1186 var compiler = test.configuration['compiler']; | 1174 var compiler = test.configuration['compiler']; |
| 1187 var runners = _batchProcesses[compiler]; | 1175 var runners = _batchProcesses[compiler]; |
| 1188 if (runners == null) { | 1176 if (runners == null) { |
| 1189 runners = new List<BatchRunnerProcess>(_maxProcesses); | 1177 runners = new List<BatchRunnerProcess>(_maxProcesses); |
| 1190 for (int i = 0; i < _maxProcesses; i++) { | 1178 for (int i = 0; i < _maxProcesses; i++) { |
| 1191 runners[i] = new BatchRunnerProcess(test); | 1179 runners[i] = new BatchRunnerProcess(test); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1245 // the developer doesn't waste his or her time trying to fix a bunch of | 1233 // the developer doesn't waste his or her time trying to fix a bunch of |
| 1246 // tests that appear to be broken but were actually just flakes that | 1234 // tests that appear to be broken but were actually just flakes that |
| 1247 // didn't get retried because there had already been one failure. | 1235 // didn't get retried because there had already been one failure. |
| 1248 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests; | 1236 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests; |
| 1249 new RunningProcess(test, allowRetry, this).start(); | 1237 new RunningProcess(test, allowRetry, this).start(); |
| 1250 } | 1238 } |
| 1251 _numProcesses++; | 1239 _numProcesses++; |
| 1252 } | 1240 } |
| 1253 } | 1241 } |
| 1254 } | 1242 } |
| OLD | NEW |