Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: tools/testing/dart/test_runner.dart

Issue 11343009: Get rid of 'close' on process. It is very easy to use incorrectly and cut off data from your stream… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comment. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 testCase.completed(); 602 testCase.completed();
603 } 603 }
604 } 604 }
605 605
606 /** 606 /**
607 * Process exit handler called at the end of every command. It internally 607 * Process exit handler called at the end of every command. It internally
608 * treats all but the last command as compilation steps. The last command is 608 * treats all but the last command as compilation steps. The last command is
609 * the actual test and its output is analyzed in [testComplete]. 609 * the actual test and its output is analyzed in [testComplete].
610 */ 610 */
611 void stepExitHandler(int exitCode) { 611 void stepExitHandler(int exitCode) {
612 process.close();
613 process = null; 612 process = null;
614 int totalSteps = testCase.commands.length; 613 int totalSteps = testCase.commands.length;
615 String suffix =' (step $currentStep of $totalSteps)'; 614 String suffix =' (step $currentStep of $totalSteps)';
616 if (timedOut) { 615 if (timedOut) {
617 // Non-webdriver test timed out before it could complete. Webdriver tests 616 // Non-webdriver test timed out before it could complete. Webdriver tests
618 // run their own timeouts by timing from the launch of the browser (which 617 // run their own timeouts by timing from the launch of the browser (which
619 // could be delayed). 618 // could be delayed).
620 testComplete(0, true); 619 testComplete(0, true);
621 } else if (currentStep == totalSteps) { 620 } else if (currentStep == totalSteps) {
622 // Done with all test commands. 621 // Done with all test commands.
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 _executable = testCase.commands.last.executable; 754 _executable = testCase.commands.last.executable;
756 _startProcess(() { 755 _startProcess(() {
757 doStartTest(testCase); 756 doStartTest(testCase);
758 }); 757 });
759 } else if (testCase.commands.last.executable != _executable) { 758 } else if (testCase.commands.last.executable != _executable) {
760 // Restart this runner with the right executable for this test 759 // Restart this runner with the right executable for this test
761 // if needed. 760 // if needed.
762 _executable = testCase.commands.last.executable; 761 _executable = testCase.commands.last.executable;
763 _batchArguments = testCase.batchRunnerArguments; 762 _batchArguments = testCase.batchRunnerArguments;
764 _process.onExit = (exitCode) { 763 _process.onExit = (exitCode) {
765 _process.close();
766 _startProcess(() { 764 _startProcess(() {
767 doStartTest(testCase); 765 doStartTest(testCase);
768 }); 766 });
769 }; 767 };
770 _process.kill(); 768 _process.kill();
771 } else { 769 } else {
772 doStartTest(testCase); 770 doStartTest(testCase);
773 } 771 }
774 } 772 }
775 773
776 Future terminate() { 774 Future terminate() {
777 if (_process == null) return new Future.immediate(true); 775 if (_process == null) return new Future.immediate(true);
778 Completer completer = new Completer(); 776 Completer completer = new Completer();
779 Timer killTimer; 777 Timer killTimer;
780 _process.onExit = (exitCode) { 778 _process.onExit = (exitCode) {
781 _process.close();
782 if (killTimer != null) killTimer.cancel(); 779 if (killTimer != null) killTimer.cancel();
783 completer.complete(true); 780 completer.complete(true);
784 }; 781 };
785 if (_isWebDriver) { 782 if (_isWebDriver) {
786 // Use a graceful shutdown so our Selenium script can close 783 // Use a graceful shutdown so our Selenium script can close
787 // the open browser processes. On Windows, signals do not exist 784 // the open browser processes. On Windows, signals do not exist
788 // and a kill is a hard kill. 785 // and a kill is a hard kill.
789 _process.stdin.write('--terminate\n'.charCodes); 786 _process.stdin.write('--terminate\n'.charCodes);
790 787
791 // In case the run_selenium process didn't close, kill it after 30s 788 // In case the run_selenium process didn't close, kill it after 30s
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 _testStdout.add(line); 916 _testStdout.add(line);
920 line = _stdoutStream.readLine(); 917 line = _stdoutStream.readLine();
921 } 918 }
922 line = _stderrStream.readLine(); 919 line = _stderrStream.readLine();
923 while (line != null) { 920 while (line != null) {
924 _testStderr.add(line); 921 _testStderr.add(line);
925 line = _stderrStream.readLine(); 922 line = _stderrStream.readLine();
926 } 923 }
927 _stderrDrained = true; 924 _stderrDrained = true;
928 _stdoutDrained = true; 925 _stdoutDrained = true;
929 _process.close();
930 _startProcess(_reportResult); 926 _startProcess(_reportResult);
931 } else { // No active test case running. 927 } else { // No active test case running.
932 _process.close();
933 _process = null; 928 _process = null;
934 } 929 }
935 } 930 }
936 return handler; 931 return handler;
937 } 932 }
938 933
939 void _timeoutHandler(ignore) { 934 void _timeoutHandler(ignore) {
940 _process.onExit = makeExitHandler(">>> TEST TIMEOUT"); 935 _process.onExit = makeExitHandler(">>> TEST TIMEOUT");
941 _process.kill(); 936 _process.kill();
942 } 937 }
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 // Check to see if the jar was already running before the program started. 1099 // Check to see if the jar was already running before the program started.
1105 String cmd = 'ps'; 1100 String cmd = 'ps';
1106 var arg = ['aux']; 1101 var arg = ['aux'];
1107 if (Platform.operatingSystem == 'windows') { 1102 if (Platform.operatingSystem == 'windows') {
1108 cmd = 'tasklist'; 1103 cmd = 'tasklist';
1109 arg.add('/v'); 1104 arg.add('/v');
1110 } 1105 }
1111 1106
1112 Future processFuture = Process.start(cmd, arg); 1107 Future processFuture = Process.start(cmd, arg);
1113 processFuture.then((Process p) { 1108 processFuture.then((Process p) {
1109 // Drain stderr to not leak resources.
1110 p.stderr.onData = p.stderr.read;
1114 final StringInputStream stdoutStringStream = 1111 final StringInputStream stdoutStringStream =
1115 new StringInputStream(p.stdout); 1112 new StringInputStream(p.stdout);
1116 stdoutStringStream.onLine = () { 1113 stdoutStringStream.onLine = () {
1117 var line = stdoutStringStream.readLine(); 1114 var line = stdoutStringStream.readLine();
1118 while (null != line) { 1115 while (null != line) {
1119 var regexp = const RegExp(r".*selenium-server-standalone.*"); 1116 var regexp = const RegExp(r".*selenium-server-standalone.*");
1120 if (regexp.hasMatch(line)) { 1117 if (regexp.hasMatch(line)) {
1121 _seleniumAlreadyRunning = true; 1118 _seleniumAlreadyRunning = true;
1122 resumeTesting(); 1119 resumeTesting();
1123 } 1120 }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 // the developer doesn't waste his or her time trying to fix a bunch of 1283 // the developer doesn't waste his or her time trying to fix a bunch of
1287 // tests that appear to be broken but were actually just flakes that 1284 // tests that appear to be broken but were actually just flakes that
1288 // didn't get retried because there had already been one failure. 1285 // didn't get retried because there had already been one failure.
1289 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests; 1286 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests;
1290 new RunningProcess(test, allowRetry, this).start(); 1287 new RunningProcess(test, allowRetry, this).start();
1291 } 1288 }
1292 _numProcesses++; 1289 _numProcesses++;
1293 } 1290 }
1294 } 1291 }
1295 } 1292 }
OLDNEW
« no previous file with comments | « tests/standalone/io/process_working_directory_test.dart ('k') | tools/testing/dart/test_suite.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698