Chromium Code Reviews| Index: tools/testing/dart/test_runner.dart |
| diff --git a/tools/testing/dart/test_runner.dart b/tools/testing/dart/test_runner.dart |
| index 73c4574068ad99f4e515d13332a0f2a7d2faaf79..683fe73b0b5049d3747dd02c509490c429dd9236 100644 |
| --- a/tools/testing/dart/test_runner.dart |
| +++ b/tools/testing/dart/test_runner.dart |
| @@ -176,8 +176,30 @@ class DartcBatchRunnerProcess { |
| bool get active() => _currentTest != null; |
| void startTest(TestCase testCase) { |
| - _startTime = new Date.now(); |
| _currentTest = testCase; |
| + if (testCase.executablePath != _executable) { |
| + // Restart this runner with the right executable for this test. |
| + _executable = testCase.executablePath; |
| + _process.exitHandler = (exitCode) { |
| + _process.close(); |
| + _startProcess(); |
| + doStartTest(testCase); |
| + }; |
| + _process.kill(); |
| + } else { |
| + doStartTest(testCase); |
| + } |
| + } |
| + |
| + void terminate() { |
| + _process.exitHandler = (exitCode) { |
| + _process.close(); |
| + }; |
| + _process.kill(); |
| + } |
| + |
| + void doStartTest(TestCase testCase) { |
| + _startTime = new Date.now(); |
| _testStdout = new List<String>(); |
| _testStderr = new List<String>(); |
| _stdoutStream.dataHandler = _readOutput(_stdoutStream, _testStdout); |
| @@ -188,13 +210,6 @@ class DartcBatchRunnerProcess { |
| _process.stdin.write(_createArgumentsLine(testCase.arguments).charCodes()); |
| } |
| - void terminate() { |
| - _process.exitHandler = (exitCode) { |
| - _process.close(); |
| - }; |
| - _process.kill(); |
| - } |
| - |
| String _createArgumentsLine(List<String> arguments) { |
| var buffer = new StringBuffer(); |
| for (var i = 0; i < arguments.length; i++) { |
| @@ -281,22 +296,21 @@ class ProcessQueue { |
| int _numProcesses = 0; |
| int _activeTestListers = 0; |
| int _maxProcesses; |
| + Function _enqueueMoreWork; |
| Queue<TestCase> _tests; |
| ProgressIndicator _progress; |
| - |
| - // For dartc batch processing we keep a list of batch processes for |
| - // each of debug and release mode. If dartc tests are run in both |
| - // release and debug mode this will spawn many processes but only |
| - // half of them will be active at a time. |
| - Map<String, List<DartcBatchRunnerProcess>> _batchProcessesMap; |
| + // For dartc batch processing we keep a list of batch processes. |
| + List<DartcBatchRunnerProcess> _batchProcesses; |
| ProcessQueue(int this._maxProcesses, |
| String progress, |
| - Date start_time) |
| + Date start_time, |
| + Function this._enqueueMoreWork) |
| : _tests = new Queue<TestCase>(), |
| _progress = new ProgressIndicator.fromName(progress, start_time), |
| - _batchProcessesMap = new Map<String, List<DartcBatchRunnerProcess>>() { |
| + _batchProcesses = new List<DartcBatchRunnerProcess>() { |
| _maxProcesses = _maxProcesses; |
| + if (!_enqueueMoreWork(this)) _progress.allDone(); |
| } |
| void addTestSuite(TestSuite testSuite) { |
| @@ -310,7 +324,10 @@ class ProcessQueue { |
| } |
| void _checkDone() { |
| - if (_activeTestListers == 0 && _tests.isEmpty() && _numProcesses == 0) { |
| + if (_activeTestListers == 0 && |
| + !_enqueueMoreWork(this) && |
|
Bill Hesse
2011/12/02 13:10:06
Should you comment here that enqueueMoreWork is an
Mads Ager (google)
2011/12/02 13:32:49
Yes, I should. Thanks.
|
| + _tests.isEmpty() && |
| + _numProcesses == 0) { |
| _terminateDartcBatchRunners(); |
| _progress.allDone(); |
| } |
| @@ -323,32 +340,20 @@ class ProcessQueue { |
| } |
| void _terminateDartcBatchRunners() { |
| - _batchProcessesMap.forEach((key, value) { |
| - for (int i = 0; i < value.length; i++) { |
| - value[i].terminate(); |
| - } |
| - }); |
| + _batchProcesses.forEach((runner) => runner.terminate()); |
| } |
| - DartcBatchRunnerProcess _getDartcBatchRunnerProcess(TestCase test) { |
| - var batchProcesses = _batchProcessesMap[test.executablePath]; |
| - if (batchProcesses == null) { |
| - // Dartc batch processing is heavy. Scale down the number of |
| - // concurrent tasks to be no more than the actual number of |
| - // processors even when running dartc benchmarks in both debug |
| - // and release mode. |
| - var processors = new Platform().numberOfProcessors(); |
| - if (_maxProcesses >= (processors / 2)) { |
| - _maxProcesses = (processors / 2).toInt(); |
| - } |
| - batchProcesses = new List<DartcBatchRunnerProcess>(_maxProcesses); |
| - _batchProcessesMap[test.executablePath] = batchProcesses; |
| + void _ensureDartcBatchRunnersStarted(String executable) { |
| + if (_batchProcesses.length == 0) { |
| for (int i = 0; i < _maxProcesses; i++) { |
| - batchProcesses[i] = new DartcBatchRunnerProcess(test.executablePath); |
| + _batchProcesses.add(new DartcBatchRunnerProcess(executable)); |
| } |
| } |
| - for (int i = 0; i < batchProcesses.length; i++) { |
| - var runner = batchProcesses[i]; |
| + } |
| + |
| + DartcBatchRunnerProcess _getDartcBatchRunnerProcess() { |
| + for (int i = 0; i < _batchProcesses.length; i++) { |
| + var runner = _batchProcesses[i]; |
| if (!runner.active) return runner; |
| } |
| throw new Exception('Unable to find inactive batch runner.'); |
| @@ -367,8 +372,9 @@ class ProcessQueue { |
| oldCallback(test_arg); |
| }; |
| test.completedHandler = wrapper; |
| - if (test.executablePath.contains('dartc_test')) { |
| - _getDartcBatchRunnerProcess(test).startTest(test); |
| + if (test.executablePath.contains('compiler')) { |
| + _ensureDartcBatchRunnersStarted(test.executablePath); |
| + _getDartcBatchRunnerProcess().startTest(test); |
| } else { |
| new RunningProcess(test).start(); |
| } |