| 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 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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; |
| 669 _currentTest = null; | 669 _currentTest = null; |
| 670 test.completed(); | 670 test.completed(); |
| 671 } | 671 } |
| 672 | 672 |
| 673 int _reportResult(String output) { | 673 int _reportResult(String output) { |
| 674 print ("_stdoutDrained: ${_currentTest.displayName}"); |
| 674 _stdoutDrained = true; | 675 _stdoutDrained = true; |
| 675 // output = '>>> TEST {PASS, FAIL, OK, CRASH, FAIL, TIMEOUT}' | 676 // output = '>>> TEST {PASS, FAIL, OK, CRASH, FAIL, TIMEOUT}' |
| 676 var outcome = output.split(" ")[2]; | 677 var outcome = output.split(" ")[2]; |
| 677 var exitCode = 0; | 678 var exitCode = 0; |
| 678 if (outcome == "CRASH") exitCode = -10; | 679 if (outcome == "CRASH") exitCode = -10; |
| 679 if (outcome == "FAIL" || outcome == "TIMEOUT") exitCode = 1; | 680 if (outcome == "FAIL" || outcome == "TIMEOUT") exitCode = 1; |
| 680 new TestOutput.fromCase(_currentTest, exitCode, outcome == "TIMEOUT", | 681 new TestOutput.fromCase(_currentTest, exitCode, outcome == "TIMEOUT", |
| 681 _testStdout, _testStderr, new Date.now().difference(_startTim
e)); | 682 _testStdout, _testStderr, new Date.now().difference(_startTim
e)); |
| 682 // Move on when both stdout and stderr has been drained. | 683 // Move on when both stdout and stderr has been drained. |
| 683 if (_stderrDrained) _testCompleted(); | 684 if (_stderrDrained) _testCompleted(); |
| 684 } | 685 } |
| 685 | 686 |
| 686 void _stderrDone() { | 687 void _stderrDone() { |
| 688 print ("_stdoutDrained: ${_currentTest.displayName}"); |
| 687 _stderrDrained = true; | 689 _stderrDrained = true; |
| 688 // Move on when both stdout and stderr has been drained. | 690 // Move on when both stdout and stderr has been drained. |
| 689 if (_stdoutDrained) _testCompleted(); | 691 if (_stdoutDrained) _testCompleted(); |
| 690 } | 692 } |
| 691 | 693 |
| 692 Function _readStdout(StringInputStream stream, List<String> buffer) { | 694 Function _readStdout(StringInputStream stream, List<String> buffer) { |
| 693 return () { | 695 return () { |
| 694 var status; | 696 var status; |
| 695 var line = stream.readLine(); | 697 var line = stream.readLine(); |
| 696 while (line != null) { | 698 while (line != null) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 725 buffer.add(line); | 727 buffer.add(line); |
| 726 } | 728 } |
| 727 line = stream.readLine(); | 729 line = stream.readLine(); |
| 728 } | 730 } |
| 729 }; | 731 }; |
| 730 } | 732 } |
| 731 | 733 |
| 732 void _exitHandler(exitCode) { | 734 void _exitHandler(exitCode) { |
| 733 if (_timer != null) _timer.cancel(); | 735 if (_timer != null) _timer.cancel(); |
| 734 _process.close(); | 736 _process.close(); |
| 737 if (!(_stdoutDrained && stderrDrained)) { |
| 738 print("*** POTENTIAL DEADLOCK on process restart"); |
| 739 } |
| 735 _startProcess(() { | 740 _startProcess(() { |
| 736 _reportResult(">>> TEST CRASH"); | 741 _reportResult(">>> TEST CRASH"); |
| 737 }); | 742 }); |
| 738 } | 743 } |
| 739 | 744 |
| 740 void _timeoutHandler(ignore) { | 745 void _timeoutHandler(ignore) { |
| 741 _process.onExit = (exitCode) { | 746 _process.onExit = (exitCode) { |
| 742 _process.close(); | 747 _process.close(); |
| 743 _startProcess(() { | 748 _startProcess(() { |
| 744 _reportResult(">>> TEST TIMEOUT"); | 749 _reportResult(">>> TEST TIMEOUT"); |
| (...skipping 381 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 | 1131 // 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 | 1132 // tests that appear to be broken but were actually just flakes that |
| 1128 // didn't get retried because there had already been one failure. | 1133 // didn't get retried because there had already been one failure. |
| 1129 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests; | 1134 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests; |
| 1130 new RunningProcess(test, allowRetry, this).start(); | 1135 new RunningProcess(test, allowRetry, this).start(); |
| 1131 } | 1136 } |
| 1132 _numProcesses++; | 1137 _numProcesses++; |
| 1133 } | 1138 } |
| 1134 } | 1139 } |
| 1135 } | 1140 } |
| OLD | NEW |