| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 #library("test_runner"); | 5 #library("test_runner"); |
| 6 | 6 |
| 7 #import("status_file_parser.dart"); | 7 #import("status_file_parser.dart"); |
| 8 #import("test_progress.dart"); | 8 #import("test_progress.dart"); |
| 9 #import("test_suite.dart"); | 9 #import("test_suite.dart"); |
| 10 | 10 |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 _process.startHandler = then; | 378 _process.startHandler = then; |
| 379 } | 379 } |
| 380 } | 380 } |
| 381 | 381 |
| 382 | 382 |
| 383 class ProcessQueue { | 383 class ProcessQueue { |
| 384 int _numProcesses = 0; | 384 int _numProcesses = 0; |
| 385 int _activeTestListers = 0; | 385 int _activeTestListers = 0; |
| 386 int _maxProcesses; | 386 int _maxProcesses; |
| 387 bool _verbose; | 387 bool _verbose; |
| 388 bool _listTests; |
| 388 Function _enqueueMoreWork; | 389 Function _enqueueMoreWork; |
| 389 Queue<TestCase> _tests; | 390 Queue<TestCase> _tests; |
| 390 ProgressIndicator _progress; | 391 ProgressIndicator _progress; |
| 391 // For dartc batch processing we keep a list of batch processes. | 392 // For dartc batch processing we keep a list of batch processes. |
| 392 List<DartcBatchRunnerProcess> _batchProcesses; | 393 List<DartcBatchRunnerProcess> _batchProcesses; |
| 393 // Cache information about test cases per test suite. For multiple | 394 // Cache information about test cases per test suite. For multiple |
| 394 // configurations there is no need to repeatedly search the file | 395 // configurations there is no need to repeatedly search the file |
| 395 // system, generate tests, and search test files for options. | 396 // system, generate tests, and search test files for options. |
| 396 Map<String, List<TestInformation>> _testCache; | 397 Map<String, List<TestInformation>> _testCache; |
| 397 | 398 |
| 398 ProcessQueue(int this._maxProcesses, | 399 ProcessQueue(int this._maxProcesses, |
| 399 String progress, | 400 String progress, |
| 400 bool this._verbose, | |
| 401 Date startTime, | 401 Date startTime, |
| 402 bool printTiming, | 402 bool printTiming, |
| 403 Function this._enqueueMoreWork) | 403 Function this._enqueueMoreWork, |
| 404 [bool verbose = false, |
| 405 bool listTests = false]) |
| 404 : _tests = new Queue<TestCase>(), | 406 : _tests = new Queue<TestCase>(), |
| 405 _progress = new ProgressIndicator.fromName(progress, | 407 _progress = new ProgressIndicator.fromName(progress, |
| 406 startTime, | 408 startTime, |
| 407 printTiming), | 409 printTiming), |
| 408 _batchProcesses = new List<DartcBatchRunnerProcess>(), | 410 _batchProcesses = new List<DartcBatchRunnerProcess>(), |
| 409 _testCache = new Map<String, List<TestInformation>>() { | 411 _testCache = new Map<String, List<TestInformation>>(), |
| 412 _verbose = verbose, |
| 413 _listTests = listTests { |
| 410 if (!_enqueueMoreWork(this)) _progress.allDone(); | 414 if (!_enqueueMoreWork(this)) _progress.allDone(); |
| 411 } | 415 } |
| 412 | 416 |
| 413 void addTestSuite(TestSuite testSuite) { | 417 void addTestSuite(TestSuite testSuite) { |
| 414 _activeTestListers++; | 418 _activeTestListers++; |
| 415 testSuite.forEachTest(_runTest, _testCache, _testListerDone); | 419 testSuite.forEachTest(_runTest, _testCache, _testListerDone); |
| 416 } | 420 } |
| 417 | 421 |
| 418 void _testListerDone() { | 422 void _testListerDone() { |
| 419 _activeTestListers--; | 423 _activeTestListers--; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 if (!runner.active) return runner; | 460 if (!runner.active) return runner; |
| 457 } | 461 } |
| 458 throw new Exception('Unable to find inactive batch runner.'); | 462 throw new Exception('Unable to find inactive batch runner.'); |
| 459 } | 463 } |
| 460 | 464 |
| 461 void _tryRunTest() { | 465 void _tryRunTest() { |
| 462 _checkDone(); | 466 _checkDone(); |
| 463 if (_numProcesses < _maxProcesses && !_tests.isEmpty()) { | 467 if (_numProcesses < _maxProcesses && !_tests.isEmpty()) { |
| 464 TestCase test = _tests.removeFirst(); | 468 TestCase test = _tests.removeFirst(); |
| 465 if (_verbose) print(test.commandLine); | 469 if (_verbose) print(test.commandLine); |
| 470 if (_listTests) { |
| 471 print(test.commandLine); |
| 472 return; |
| 473 } |
| 466 _progress.start(test); | 474 _progress.start(test); |
| 467 Function oldCallback = test.completedHandler; | 475 Function oldCallback = test.completedHandler; |
| 468 Function wrapper = (TestCase test_arg) { | 476 Function wrapper = (TestCase test_arg) { |
| 469 _numProcesses--; | 477 _numProcesses--; |
| 470 _progress.done(test_arg); | 478 _progress.done(test_arg); |
| 471 _tryRunTest(); | 479 _tryRunTest(); |
| 472 oldCallback(test_arg); | 480 oldCallback(test_arg); |
| 473 }; | 481 }; |
| 474 test.completedHandler = wrapper; | 482 test.completedHandler = wrapper; |
| 475 if (test.configuration['component'] == 'dartc' && | 483 if (test.configuration['component'] == 'dartc' && |
| 476 test.displayName != 'dartc/junit_tests') { | 484 test.displayName != 'dartc/junit_tests') { |
| 477 _ensureDartcBatchRunnersStarted(test.executablePath); | 485 _ensureDartcBatchRunnersStarted(test.executablePath); |
| 478 _getDartcBatchRunnerProcess().startTest(test); | 486 _getDartcBatchRunnerProcess().startTest(test); |
| 479 } else { | 487 } else { |
| 480 new RunningProcess(test).start(); | 488 new RunningProcess(test).start(); |
| 481 } | 489 } |
| 482 _numProcesses++; | 490 _numProcesses++; |
| 483 } | 491 } |
| 484 } | 492 } |
| 485 } | 493 } |
| OLD | NEW |