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

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

Issue 15563002: Correctly set the timeout of tests when using selenium (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 months 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
« no previous file with comments | « no previous file | tools/testing/dart/test_suite.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 952 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 field = new StringBuffer(); 963 field = new StringBuffer();
964 continue; 964 continue;
965 } 965 }
966 field.write(c); 966 field.write(c);
967 } 967 }
968 result.add(field.toString()); 968 result.add(field.toString());
969 return result; 969 return result;
970 } 970 }
971 } 971 }
972 972
973
974 /** Modifies the --timeout=XX parameter passed to run_selenium.py */
975 List<String> _modifySeleniumTimeout(List<String> arguments, int timeout) {
976 return arguments.map((argument) {
977 if (argument.startsWith('--timeout=')) {
978 return "--timeout=$timeout";
979 } else {
980 return argument;
981 }
982 }).toList();
983 return;
984 }
985
986
973 /** 987 /**
974 * A RunningProcess actually runs a test, getting the command lines from 988 * A RunningProcess actually runs a test, getting the command lines from
975 * its [TestCase], starting the test process (and first, a compilation 989 * its [TestCase], starting the test process (and first, a compilation
976 * process if the TestCase is a [BrowserTestCase]), creating a timeout 990 * process if the TestCase is a [BrowserTestCase]), creating a timeout
977 * timer, and recording the results in a new [CommandOutput] object, which it 991 * timer, and recording the results in a new [CommandOutput] object, which it
978 * attaches to the TestCase. The lifetime of the RunningProcess is limited 992 * attaches to the TestCase. The lifetime of the RunningProcess is limited
979 * to the time it takes to start the process, run the process, and record 993 * to the time it takes to start the process, run the process, and record
980 * the result; there are no pointers to it, so it should be available to 994 * the result; there are no pointers to it, so it should be available to
981 * be garbage collected as soon as it is done. 995 * be garbage collected as soon as it is done.
982 */ 996 */
(...skipping 21 matching lines...) Expand all
1004 return completer.future; 1018 return completer.future;
1005 } 1019 }
1006 1020
1007 void _runCommand() { 1021 void _runCommand() {
1008 command.outputIsUpToDate.then((bool isUpToDate) { 1022 command.outputIsUpToDate.then((bool isUpToDate) {
1009 if (isUpToDate) { 1023 if (isUpToDate) {
1010 compilationSkipped = true; 1024 compilationSkipped = true;
1011 _commandComplete(0); 1025 _commandComplete(0);
1012 } else { 1026 } else {
1013 var processOptions = _createProcessOptions(); 1027 var processOptions = _createProcessOptions();
1028 var commandArguments = _modifySeleniumTimeout(command.arguments,
1029 testCase.timeout);
1014 Future processFuture = io.Process.start(command.executable, 1030 Future processFuture = io.Process.start(command.executable,
1015 command.arguments, 1031 commandArguments,
1016 processOptions); 1032 processOptions);
1017 processFuture.then((io.Process process) { 1033 processFuture.then((io.Process process) {
1018 // Close stdin so that tests that try to block on input will fail. 1034 // Close stdin so that tests that try to block on input will fail.
1019 process.stdin.close(); 1035 process.stdin.close();
1020 void timeoutHandler() { 1036 void timeoutHandler() {
1021 timedOut = true; 1037 timedOut = true;
1022 if (process != null) { 1038 if (process != null) {
1023 process.kill(); 1039 process.kill();
1024 } 1040 }
1025 } 1041 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 _stdoutCompleter = new Completer(); 1186 _stdoutCompleter = new Completer();
1171 _stderrCompleter = new Completer(); 1187 _stderrCompleter = new Completer();
1172 _timer = new Timer(new Duration(seconds: testCase.timeout), 1188 _timer = new Timer(new Duration(seconds: testCase.timeout),
1173 _timeoutHandler); 1189 _timeoutHandler);
1174 1190
1175 if (testCase.commands.last.environment != null) { 1191 if (testCase.commands.last.environment != null) {
1176 print("Warning: command.environment != null, but we don't support custom " 1192 print("Warning: command.environment != null, but we don't support custom "
1177 "environments for batch runner tests!"); 1193 "environments for batch runner tests!");
1178 } 1194 }
1179 1195
1180 var line = _createArgumentsLine(testCase.batchTestArguments); 1196 var line = _createArgumentsLine(testCase.batchTestArguments,
1197 testCase.timeout);
1181 _process.stdin.write(line); 1198 _process.stdin.write(line);
1182 _stdoutSubscription.resume(); 1199 _stdoutSubscription.resume();
1183 _stderrSubscription.resume(); 1200 _stderrSubscription.resume();
1184 Future.wait([_stdoutCompleter.future, 1201 Future.wait([_stdoutCompleter.future,
1185 _stderrCompleter.future]).then((_) => _reportResult()); 1202 _stderrCompleter.future]).then((_) => _reportResult());
1186 } 1203 }
1187 1204
1188 String _createArgumentsLine(List<String> arguments) { 1205 String _createArgumentsLine(List<String> arguments, int timeout) {
1206 arguments = _modifySeleniumTimeout(arguments, timeout);
1189 return arguments.join(' ').concat('\n'); 1207 return arguments.join(' ').concat('\n');
1190 } 1208 }
1191 1209
1192 void _reportResult() { 1210 void _reportResult() {
1193 if (!active) return; 1211 if (!active) return;
1194 // _status == '>>> TEST {PASS, FAIL, OK, CRASH, FAIL, TIMEOUT}' 1212 // _status == '>>> TEST {PASS, FAIL, OK, CRASH, FAIL, TIMEOUT}'
1195 1213
1196 var outcome = _status.split(" ")[2]; 1214 var outcome = _status.split(" ")[2];
1197 var exitCode = 0; 1215 var exitCode = 0;
1198 if (outcome == "CRASH") exitCode = CRASHING_BROWSER_EXITCODE; 1216 if (outcome == "CRASH") exitCode = CRASHING_BROWSER_EXITCODE;
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
1845 } 1863 }
1846 } 1864 }
1847 1865
1848 void eventAllTestsDone() { 1866 void eventAllTestsDone() {
1849 for (var listener in _eventListener) { 1867 for (var listener in _eventListener) {
1850 listener.allDone(); 1868 listener.allDone();
1851 } 1869 }
1852 } 1870 }
1853 } 1871 }
1854 1872
OLDNEW
« no previous file with comments | « no previous file | tools/testing/dart/test_suite.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698