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

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

Issue 8835008: Correctly handle the --arch argument to dart test scripts. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix typo Created 9 years 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 | « tools/testing/dart/test_options.dart ('k') | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 #library("test_runner"); 5 #library("test_runner");
6 6
7 #import("status_file_parser.dart"); 7 #import("status_file_parser.dart");
8 #import("test_progress.dart"); 8 #import("test_progress.dart");
9 #import("test_suite.dart"); 9 #import("test_suite.dart");
10 10
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 _testStderr = new List<String>(); 204 _testStderr = new List<String>();
205 _stdoutStream.dataHandler = _readOutput(_stdoutStream, _testStdout); 205 _stdoutStream.dataHandler = _readOutput(_stdoutStream, _testStdout);
206 _stderrStream.dataHandler = _readOutput(_stderrStream, _testStderr); 206 _stderrStream.dataHandler = _readOutput(_stderrStream, _testStderr);
207 _timer = new Timer(_timeoutHandler(testCase), 207 _timer = new Timer(_timeoutHandler(testCase),
208 testCase.timeout * 1000, 208 testCase.timeout * 1000,
209 false); 209 false);
210 _process.stdin.write(_createArgumentsLine(testCase.arguments).charCodes()); 210 _process.stdin.write(_createArgumentsLine(testCase.arguments).charCodes());
211 } 211 }
212 212
213 String _createArgumentsLine(List<String> arguments) { 213 String _createArgumentsLine(List<String> arguments) {
214 var buffer = new StringBuffer(); 214 return Strings.join(arguments, ' ') + '\n';
215 for (var i = 0; i < arguments.length; i++) {
216 buffer.add("${arguments[i]} ");
217 }
218 buffer.add("\n");
219 return buffer.toString();
220 } 215 }
221 216
222 int _reportResult(String output) { 217 int _reportResult(String output) {
223 var test = _currentTest; 218 var test = _currentTest;
224 _currentTest = null; 219 _currentTest = null;
225 220
226 // output = '>>> TEST {PASS, FAIL, OK, CRASH, FAIL, TIMEOUT}' 221 // output = '>>> TEST {PASS, FAIL, OK, CRASH, FAIL, TIMEOUT}'
227 var outcome = output.split(" ")[2]; 222 var outcome = output.split(" ")[2];
228 var exitCode = 0; 223 var exitCode = 0;
229 if (outcome == "CRASH") exitCode = -10; 224 if (outcome == "CRASH") exitCode = -10;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 _process.exitHandler = _exitHandler; 284 _process.exitHandler = _exitHandler;
290 _process.start(); 285 _process.start();
291 } 286 }
292 } 287 }
293 288
294 289
295 class ProcessQueue { 290 class ProcessQueue {
296 int _numProcesses = 0; 291 int _numProcesses = 0;
297 int _activeTestListers = 0; 292 int _activeTestListers = 0;
298 int _maxProcesses; 293 int _maxProcesses;
294 bool _verbose;
299 Function _enqueueMoreWork; 295 Function _enqueueMoreWork;
300 Queue<TestCase> _tests; 296 Queue<TestCase> _tests;
301 ProgressIndicator _progress; 297 ProgressIndicator _progress;
302 // For dartc batch processing we keep a list of batch processes. 298 // For dartc batch processing we keep a list of batch processes.
303 List<DartcBatchRunnerProcess> _batchProcesses; 299 List<DartcBatchRunnerProcess> _batchProcesses;
304 300
305 ProcessQueue(int this._maxProcesses, 301 ProcessQueue(int this._maxProcesses,
306 String progress, 302 String progress,
303 bool this._verbose,
307 Date start_time, 304 Date start_time,
308 Function this._enqueueMoreWork) 305 Function this._enqueueMoreWork)
309 : _tests = new Queue<TestCase>(), 306 : _tests = new Queue<TestCase>(),
310 _progress = new ProgressIndicator.fromName(progress, start_time), 307 _progress = new ProgressIndicator.fromName(progress, start_time),
311 _batchProcesses = new List<DartcBatchRunnerProcess>() { 308 _batchProcesses = new List<DartcBatchRunnerProcess>() {
312 _maxProcesses = _maxProcesses;
313 if (!_enqueueMoreWork(this)) _progress.allDone(); 309 if (!_enqueueMoreWork(this)) _progress.allDone();
314 } 310 }
315 311
316 void addTestSuite(TestSuite testSuite) { 312 void addTestSuite(TestSuite testSuite) {
317 _activeTestListers++; 313 _activeTestListers++;
318 testSuite.forEachTest(_runTest, _testListerDone); 314 testSuite.forEachTest(_runTest, _testListerDone);
319 } 315 }
320 316
321 void _testListerDone() { 317 void _testListerDone() {
322 _activeTestListers--; 318 _activeTestListers--;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 } 350 }
355 351
356 DartcBatchRunnerProcess _getDartcBatchRunnerProcess() { 352 DartcBatchRunnerProcess _getDartcBatchRunnerProcess() {
357 for (int i = 0; i < _batchProcesses.length; i++) { 353 for (int i = 0; i < _batchProcesses.length; i++) {
358 var runner = _batchProcesses[i]; 354 var runner = _batchProcesses[i];
359 if (!runner.active) return runner; 355 if (!runner.active) return runner;
360 } 356 }
361 throw new Exception('Unable to find inactive batch runner.'); 357 throw new Exception('Unable to find inactive batch runner.');
362 } 358 }
363 359
360 void _printTestCase(TestCase testCase) {
361 var path = testCase.executablePath;
362 var args = Strings.join(testCase.arguments, ' ');
363 print('# $path $args');
364 }
365
364 void _tryRunTest() { 366 void _tryRunTest() {
365 _checkDone(); 367 _checkDone();
366 if (_numProcesses < _maxProcesses && !_tests.isEmpty()) { 368 if (_numProcesses < _maxProcesses && !_tests.isEmpty()) {
367 TestCase test = _tests.removeFirst(); 369 TestCase test = _tests.removeFirst();
370 if (_verbose) _printTestCase(test);
368 _progress.start(test); 371 _progress.start(test);
369 Function oldCallback = test.completedHandler; 372 Function oldCallback = test.completedHandler;
370 Function wrapper = (TestCase test_arg) { 373 Function wrapper = (TestCase test_arg) {
371 _numProcesses--; 374 _numProcesses--;
372 _progress.done(test_arg); 375 _progress.done(test_arg);
373 _tryRunTest(); 376 _tryRunTest();
374 oldCallback(test_arg); 377 oldCallback(test_arg);
375 }; 378 };
376 test.completedHandler = wrapper; 379 test.completedHandler = wrapper;
377 if (test.executablePath.contains('compiler')) { 380 if (test.executablePath.contains('compiler')) {
378 _ensureDartcBatchRunnersStarted(test.executablePath); 381 _ensureDartcBatchRunnersStarted(test.executablePath);
379 _getDartcBatchRunnerProcess().startTest(test); 382 _getDartcBatchRunnerProcess().startTest(test);
380 } else { 383 } else {
381 new RunningProcess(test).start(); 384 new RunningProcess(test).start();
382 } 385 }
383 _numProcesses++; 386 _numProcesses++;
384 } 387 }
385 } 388 }
386 } 389 }
OLDNEW
« no previous file with comments | « tools/testing/dart/test_options.dart ('k') | tools/testing/dart/test_suite.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698