| 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 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 _testStdout = []; | 728 _testStdout = []; |
| 729 _testStderr = []; | 729 _testStderr = []; |
| 730 _status = null; | 730 _status = null; |
| 731 _stdoutDrained = false; | 731 _stdoutDrained = false; |
| 732 _stderrDrained = false; | 732 _stderrDrained = false; |
| 733 _ignoreStreams = new MutableValue<bool>(false); // Captured by closures. | 733 _ignoreStreams = new MutableValue<bool>(false); // Captured by closures. |
| 734 _stdoutStream.onLine = _readStdout(_stdoutStream, _testStdout); | 734 _stdoutStream.onLine = _readStdout(_stdoutStream, _testStdout); |
| 735 _stderrStream.onLine = _readStderr(_stderrStream, _testStderr); | 735 _stderrStream.onLine = _readStderr(_stderrStream, _testStderr); |
| 736 _timer = new Timer(testCase.timeout * 1000, _timeoutHandler); | 736 _timer = new Timer(testCase.timeout * 1000, _timeoutHandler); |
| 737 var line = _createArgumentsLine(testCase.batchTestArguments); | 737 var line = _createArgumentsLine(testCase.batchTestArguments); |
| 738 _process.stdin.onError = (err) { |
| 739 print('Error on batch runner input stream stdin'); |
| 740 print(' Input line: $line'); |
| 741 print(' Previous test\'s status: $_status'); |
| 742 print(' Error: $err'); |
| 743 throw err; |
| 744 }; |
| 738 _process.stdin.write(line.charCodes()); | 745 _process.stdin.write(line.charCodes()); |
| 739 } | 746 } |
| 740 | 747 |
| 741 String _createArgumentsLine(List<String> arguments) { | 748 String _createArgumentsLine(List<String> arguments) { |
| 742 return Strings.join(arguments, ' ').concat('\n'); | 749 return Strings.join(arguments, ' ').concat('\n'); |
| 743 } | 750 } |
| 744 | 751 |
| 745 void _reportResult() { | 752 void _reportResult() { |
| 746 if (!active) return; | 753 if (!active) return; |
| 747 // _status == '>>> TEST {PASS, FAIL, OK, CRASH, FAIL, TIMEOUT}' | 754 // _status == '>>> TEST {PASS, FAIL, OK, CRASH, FAIL, TIMEOUT}' |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 while (line != null) { | 845 while (line != null) { |
| 839 _testStderr.add(line); | 846 _testStderr.add(line); |
| 840 line = _stderrStream.readLine(); | 847 line = _stderrStream.readLine(); |
| 841 } | 848 } |
| 842 _stderrDrained = true; | 849 _stderrDrained = true; |
| 843 _stdoutDrained = true; | 850 _stdoutDrained = true; |
| 844 _process.close(); | 851 _process.close(); |
| 845 _startProcess(() { _reportResult(); }); | 852 _startProcess(() { _reportResult(); }); |
| 846 } else { // No active test case running. | 853 } else { // No active test case running. |
| 847 _process.close(); | 854 _process.close(); |
| 848 _startProcess(() { }); | 855 _process = null; |
| 849 } | 856 } |
| 850 }; | 857 }; |
| 851 } | 858 } |
| 852 | 859 |
| 853 void _timeoutHandler(ignore) { | 860 void _timeoutHandler(ignore) { |
| 854 _process.onExit = makeExitHandler(">>> TEST TIMEOUT"); | 861 _process.onExit = makeExitHandler(">>> TEST TIMEOUT"); |
| 855 _process.kill(); | 862 _process.kill(); |
| 856 } | 863 } |
| 857 | 864 |
| 858 void _startProcess(then) { | 865 void _startProcess(then) { |
| 859 _process = Process.start(_executable, _batchArguments); | 866 _process = Process.start(_executable, _batchArguments); |
| 860 _stdoutStream = new StringInputStream(_process.stdout); | 867 _stdoutStream = new StringInputStream(_process.stdout); |
| 861 _stderrStream = new StringInputStream(_process.stderr); | 868 _stderrStream = new StringInputStream(_process.stderr); |
| 862 _process.onExit = makeExitHandler(">>> TEST CRASH"); | 869 _process.onExit = makeExitHandler(">>> TEST CRASH"); |
| 863 _process.onError = (e) { | 870 _process.onError = (e) { |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1170 // the developer doesn't waste his or her time trying to fix a bunch of | 1177 // the developer doesn't waste his or her time trying to fix a bunch of |
| 1171 // tests that appear to be broken but were actually just flakes that | 1178 // tests that appear to be broken but were actually just flakes that |
| 1172 // didn't get retried because there had already been one failure. | 1179 // didn't get retried because there had already been one failure. |
| 1173 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests; | 1180 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests; |
| 1174 new RunningProcess(test, allowRetry, this).start(); | 1181 new RunningProcess(test, allowRetry, this).start(); |
| 1175 } | 1182 } |
| 1176 _numProcesses++; | 1183 _numProcesses++; |
| 1177 } | 1184 } |
| 1178 } | 1185 } |
| 1179 } | 1186 } |
| OLD | NEW |