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

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

Issue 9240011: Add temporary directory for dartc compilation of tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use the correct version of DeMorgan's law when rearranging if statements. Created 8 years, 11 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
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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 } 399 }
400 } 400 }
401 401
402 402
403 class ProcessQueue { 403 class ProcessQueue {
404 int _numProcesses = 0; 404 int _numProcesses = 0;
405 int _activeTestListers = 0; 405 int _activeTestListers = 0;
406 int _maxProcesses; 406 int _maxProcesses;
407 bool _verbose; 407 bool _verbose;
408 bool _listTests; 408 bool _listTests;
409 bool _keepGeneratedTests;
409 Function _enqueueMoreWork; 410 Function _enqueueMoreWork;
410 Queue<TestCase> _tests; 411 Queue<TestCase> _tests;
411 ProgressIndicator _progress; 412 ProgressIndicator _progress;
413 String _temporaryDirectory;
412 // For dartc batch processing we keep a list of batch processes. 414 // For dartc batch processing we keep a list of batch processes.
413 List<DartcBatchRunnerProcess> _batchProcesses; 415 List<DartcBatchRunnerProcess> _batchProcesses;
414 // Cache information about test cases per test suite. For multiple 416 // Cache information about test cases per test suite. For multiple
415 // configurations there is no need to repeatedly search the file 417 // configurations there is no need to repeatedly search the file
416 // system, generate tests, and search test files for options. 418 // system, generate tests, and search test files for options.
417 Map<String, List<TestInformation>> _testCache; 419 Map<String, List<TestInformation>> _testCache;
418 420
419 ProcessQueue(int this._maxProcesses, 421 ProcessQueue(int this._maxProcesses,
420 String progress, 422 String progress,
421 Date startTime, 423 Date startTime,
422 bool printTiming, 424 bool printTiming,
423 Function this._enqueueMoreWork, 425 Function this._enqueueMoreWork,
424 [bool verbose = false, 426 [bool verbose = false,
Mads Ager (chromium) 2012/01/18 06:57:17 We should go back to using this.verbose, this.list
Bill Hesse 2012/01/18 11:52:38 Done.
425 bool listTests = false]) 427 bool listTests = false,
428 bool keepGeneratedTests = false])
426 : _tests = new Queue<TestCase>(), 429 : _tests = new Queue<TestCase>(),
427 _progress = new ProgressIndicator.fromName(progress, 430 _progress = new ProgressIndicator.fromName(progress,
428 startTime, 431 startTime,
429 printTiming), 432 printTiming),
430 _batchProcesses = new List<DartcBatchRunnerProcess>(), 433 _batchProcesses = new List<DartcBatchRunnerProcess>(),
431 _testCache = new Map<String, List<TestInformation>>(), 434 _testCache = new Map<String, List<TestInformation>>(),
432 _verbose = verbose, 435 _verbose = verbose,
433 _listTests = listTests { 436 _listTests = listTests,
437 _keepGeneratedTests = keepGeneratedTests {
438 if (new Platform().operatingSystem() != 'windows') {
Mads Ager (chromium) 2012/01/18 06:57:17 Can we filter out better when we create the tempor
Bill Hesse 2012/01/18 11:52:38 It is the components we run, not the test suites,
439 var tempDir = new Directory('');
440 tempDir.createTempSync();
441 _temporaryDirectory = tempDir.path;
442 }
434 if (!_enqueueMoreWork(this)) _progress.allDone(); 443 if (!_enqueueMoreWork(this)) _progress.allDone();
435 } 444 }
436 445
437 void addTestSuite(TestSuite testSuite) { 446 void addTestSuite(TestSuite testSuite) {
438 _activeTestListers++; 447 _activeTestListers++;
439 testSuite.forEachTest(_runTest, _testCache, _testListerDone); 448 testSuite.forEachTest(_runTest, _testCache, _temporaryDirectory,
449 _testListerDone);
440 } 450 }
441 451
442 void _testListerDone() { 452 void _testListerDone() {
443 _activeTestListers--; 453 _activeTestListers--;
444 _checkDone(); 454 _checkDone();
445 } 455 }
446 456
447 void _checkDone() { 457 void _checkDone() {
448 // When there are no more active test listers ask for more work 458 // When there are no more active test listers ask for more work
449 // from process queue users. 459 // from process queue users.
450 if (_activeTestListers == 0 && !_enqueueMoreWork(this)) { 460 if (_activeTestListers == 0 && !_enqueueMoreWork(this)) {
451 _progress.allTestsKnown(); 461 _progress.allTestsKnown();
452 if (_tests.isEmpty() && _numProcesses == 0) { 462 if (_tests.isEmpty() && _numProcesses == 0) {
453 _terminateDartcBatchRunners(); 463 _terminateDartcBatchRunners();
454 _progress.allDone(); 464 if (_keepGeneratedTests ||
465 new Platform().operatingSystem() == 'windows') {
466 _progress.allDone();
467 } else if (!_temporaryDirectory.startsWith('/tmp/') ||
468 _temporaryDirectory.contains('/../')) {
469 // Let's be extra careful, since rm -rf is so dangerous.
470 print('Temporary directory $_temporaryDirectory unsafe to delete!');
471 _progress.allDone();
472 } else {
473 var deletion =
474 new Process.start('/bin/rm', ['-rf', _temporaryDirectory]);
Mads Ager (chromium) 2012/01/18 06:57:17 Lets add a TODO that this should be replaced by _t
Bill Hesse 2012/01/18 11:52:38 Done.
475 deletion.startHandler = (){
476 _progress.allDone();
477 };
478 deletion.close(); // Detach process - don't wait for it to finish.
Mads Ager (chromium) 2012/01/18 06:57:17 I'm not sure we should do that. It will allow the
Bill Hesse 2012/01/18 11:52:38 The deletion.close() is redundant, since _progress
479 }
455 } 480 }
456 } 481 }
457 } 482 }
458 483
459 void _runTest(TestCase test) { 484 void _runTest(TestCase test) {
460 _progress.testAdded(); 485 _progress.testAdded();
461 _tests.add(test); 486 _tests.add(test);
462 _tryRunTest(); 487 _tryRunTest();
463 } 488 }
464 489
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 test.displayName != 'dartc/junit_tests') { 529 test.displayName != 'dartc/junit_tests') {
505 _ensureDartcBatchRunnersStarted(test.executablePath); 530 _ensureDartcBatchRunnersStarted(test.executablePath);
506 _getDartcBatchRunnerProcess().startTest(test); 531 _getDartcBatchRunnerProcess().startTest(test);
507 } else { 532 } else {
508 new RunningProcess(test).start(); 533 new RunningProcess(test).start();
509 } 534 }
510 _numProcesses++; 535 _numProcesses++;
511 } 536 }
512 } 537 }
513 } 538 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698