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 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 process.onExit = exitHandler; | 558 process.onExit = exitHandler; |
559 startTime = new Date.now(); | 559 startTime = new Date.now(); |
560 InputStream stdoutStream = process.stdout; | 560 InputStream stdoutStream = process.stdout; |
561 InputStream stderrStream = process.stderr; | 561 InputStream stderrStream = process.stderr; |
562 StringInputStream stdoutStringStream = new StringInputStream(stdoutStream); | 562 StringInputStream stdoutStringStream = new StringInputStream(stdoutStream); |
563 StringInputStream stderrStringStream = new StringInputStream(stderrStream); | 563 StringInputStream stderrStringStream = new StringInputStream(stderrStream); |
564 stdoutStringStream.onLine = | 564 stdoutStringStream.onLine = |
565 makeReadHandler(stdoutStringStream, stdout); | 565 makeReadHandler(stdoutStringStream, stdout); |
566 stderrStringStream.onLine = | 566 stderrStringStream.onLine = |
567 makeReadHandler(stderrStringStream, stderr); | 567 makeReadHandler(stderrStringStream, stderr); |
568 timeoutTimer = new Timer(timeoutHandler, 1000 * testCase.timeout); | 568 timeoutTimer = new Timer(1000 * testCase.timeout, timeoutHandler); |
569 } | 569 } |
570 | 570 |
571 void timeoutHandler(Timer unusedTimer) { | 571 void timeoutHandler(Timer unusedTimer) { |
572 timedOut = true; | 572 timedOut = true; |
573 process.kill(); | 573 process.kill(); |
574 } | 574 } |
575 } | 575 } |
576 | 576 |
577 class BatchRunnerProcess { | 577 class BatchRunnerProcess { |
578 String _executable; | 578 String _executable; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 _process.close(); | 633 _process.close(); |
634 }; | 634 }; |
635 if (_isWebDriver) { | 635 if (_isWebDriver) { |
636 // Use a graceful shutdown so our Selenium script can close | 636 // Use a graceful shutdown so our Selenium script can close |
637 // the open browser processes. TODO(jmesserly): Send a signal once | 637 // the open browser processes. TODO(jmesserly): Send a signal once |
638 // that's supported, see dartbug.com/1756. | 638 // that's supported, see dartbug.com/1756. |
639 _process.stdin.write('--terminate\n'.charCodes()); | 639 _process.stdin.write('--terminate\n'.charCodes()); |
640 | 640 |
641 // In case the run_selenium process didn't close, kill it after 30s | 641 // In case the run_selenium process didn't close, kill it after 30s |
642 bool shutdownMillisecs = 30000; | 642 bool shutdownMillisecs = 30000; |
643 new Timer((e) { if (!closed) _process.kill(); }, shutdownMillisecs); | 643 new Timer(shutdownMillisecs, (e) { if (!closed) _process.kill(); }); |
644 } else { | 644 } else { |
645 _process.kill(); | 645 _process.kill(); |
646 } | 646 } |
647 } | 647 } |
648 } | 648 } |
649 | 649 |
650 void doStartTest(TestCase testCase) { | 650 void doStartTest(TestCase testCase) { |
651 _startTime = new Date.now(); | 651 _startTime = new Date.now(); |
652 _testStdout = []; | 652 _testStdout = []; |
653 _testStderr = []; | 653 _testStderr = []; |
654 _stdoutDrained = false; | 654 _stdoutDrained = false; |
655 _stderrDrained = false; | 655 _stderrDrained = false; |
656 _stdoutStream.onLine = _readStdout(_stdoutStream, _testStdout); | 656 _stdoutStream.onLine = _readStdout(_stdoutStream, _testStdout); |
657 _stderrStream.onLine = _readStderr(_stderrStream, _testStderr); | 657 _stderrStream.onLine = _readStderr(_stderrStream, _testStderr); |
658 _timer = new Timer(_timeoutHandler, testCase.timeout * 1000); | 658 _timer = new Timer(testCase.timeout * 1000, _timeoutHandler); |
659 var line = _createArgumentsLine(testCase.batchTestArguments); | 659 var line = _createArgumentsLine(testCase.batchTestArguments); |
660 _process.stdin.write(line.charCodes()); | 660 _process.stdin.write(line.charCodes()); |
661 } | 661 } |
662 | 662 |
663 String _createArgumentsLine(List<String> arguments) { | 663 String _createArgumentsLine(List<String> arguments) { |
664 return Strings.join(arguments, ' ') + '\n'; | 664 return Strings.join(arguments, ' ') + '\n'; |
665 } | 665 } |
666 | 666 |
667 void _testCompleted() { | 667 void _testCompleted() { |
668 var test = _currentTest; | 668 var test = _currentTest; |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1126 // the developer doesn't waste his or her time trying to fix a bunch of | 1126 // the developer doesn't waste his or her time trying to fix a bunch of |
1127 // tests that appear to be broken but were actually just flakes that | 1127 // tests that appear to be broken but were actually just flakes that |
1128 // didn't get retried because there had already been one failure. | 1128 // didn't get retried because there had already been one failure. |
1129 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests; | 1129 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests; |
1130 new RunningProcess(test, allowRetry, this).start(); | 1130 new RunningProcess(test, allowRetry, this).start(); |
1131 } | 1131 } |
1132 _numProcesses++; | 1132 _numProcesses++; |
1133 } | 1133 } |
1134 } | 1134 } |
1135 } | 1135 } |
OLD | NEW |