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

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

Issue 10392078: Report total time for multiphase tests, in test script's --test option, not time of last phase. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Improve long line fixes. Created 8 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 | no next file » | 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 TestOutputImpl(TestCase this.testCase, 233 TestOutputImpl(TestCase this.testCase,
234 int this.exitCode, 234 int this.exitCode,
235 bool this.timedOut, 235 bool this.timedOut,
236 List<String> this.stdout, 236 List<String> this.stdout,
237 List<String> this.stderr, 237 List<String> this.stderr,
238 Duration this.time) { 238 Duration this.time) {
239 testCase.output = this; 239 testCase.output = this;
240 diagnostics = []; 240 diagnostics = [];
241 } 241 }
242 242
243 factory TestOutputImpl.fromCase (TestCase testCase, int exitCode, bool timedOu t, 243 factory TestOutputImpl.fromCase (TestCase testCase,
244 List<String> stdout, List<String> stderr, Dur ation time) { 244 int exitCode,
245 bool timedOut,
246 List<String> stdout,
247 List<String> stderr,
248 Duration time) {
245 if (testCase is BrowserTestCase) { 249 if (testCase is BrowserTestCase) {
246 return new BrowserTestOutputImpl(testCase, exitCode, timedOut, 250 return new BrowserTestOutputImpl(testCase, exitCode, timedOut,
247 stdout, stderr, time); 251 stdout, stderr, time);
248 } else if (testCase.configuration['compiler'] == 'dartc') { 252 } else if (testCase.configuration['compiler'] == 'dartc') {
249 return new AnalysisTestOutputImpl(testCase, exitCode, timedOut, 253 return new AnalysisTestOutputImpl(testCase, exitCode, timedOut,
250 stdout, stderr, time); 254 stdout, stderr, time);
251 } 255 }
252 return new TestOutputImpl(testCase, exitCode, timedOut, 256 return new TestOutputImpl(testCase, exitCode, timedOut,
253 stdout, stderr, time); 257 stdout, stderr, time);
254 } 258 }
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 return true; 424 return true;
421 } 425 }
422 } else if (exitCode == 0) { 426 } else if (exitCode == 0) {
423 diagnostics.add("EXIT CODE MISMATCH: Unexpected error message:"); 427 diagnostics.add("EXIT CODE MISMATCH: Unexpected error message:");
424 diagnostics.add(" errors[0]:${errors[0]}"); 428 diagnostics.add(" errors[0]:${errors[0]}");
425 diagnostics.add(" command[0]:${testCase.commands[0]}"); 429 diagnostics.add(" command[0]:${testCase.commands[0]}");
426 diagnostics.add(" exitCode:${exitCode}"); 430 diagnostics.add(" exitCode:${exitCode}");
427 return true; 431 return true;
428 } 432 }
429 if (numStaticTypeAnnotations > 0 && isStaticClean) { 433 if (numStaticTypeAnnotations > 0 && isStaticClean) {
430 diagnostics.add("Cannot have both @static-clean and /// static type warnin g annotations."); 434 diagnostics.add("Cannot have both @static-clean and /// static "
435 "type warning annotations.");
431 return true; 436 return true;
432 } 437 }
433 438
434 if (isStaticClean && staticWarnings.length > 0) { 439 if (isStaticClean && staticWarnings.length > 0) {
435 diagnostics.add("@static-clean annotation found but analyzer returned warn ings."); 440 diagnostics.add(
441 "@static-clean annotation found but analyzer returned warnings.");
436 return true; 442 return true;
437 } 443 }
438 444
439 if (numCompileTimeAnnotations > 0 445 if (numCompileTimeAnnotations > 0
440 && numCompileTimeAnnotations < errors.length) { 446 && numCompileTimeAnnotations < errors.length) {
441 447 // Expected compile-time errors were not returned.
442 // Expected compile-time errors were not returned. The test did not 'fail ' in the way 448 // The test did not 'fail' in the way intended so don't return failed.
443 // intended so don't return failed. 449 diagnostics.add("Fewer compile time errors than annotated: "
444 diagnostics.add("Fewer compile time errors than annotated: ${numCompileTim eAnnotations}"); 450 "$numCompileTimeAnnotations");
445 return false; 451 return false;
446 } 452 }
447 453
448 if (numStaticTypeAnnotations > 0 || hasFatalTypeErrors) { 454 if (numStaticTypeAnnotations > 0 || hasFatalTypeErrors) {
449 // TODO(zundel): match up the annotation line numbers 455 // TODO(zundel): match up the annotation line numbers
450 // with the reported error line numbers 456 // with the reported error line numbers
451 if (staticWarnings.length < numStaticTypeAnnotations) { 457 if (staticWarnings.length < numStaticTypeAnnotations) {
452 diagnostics.add("Fewer static type warnings than annotated: ${numStaticT ypeAnnotations}"); 458 diagnostics.add("Fewer static type warnings than annotated: "
459 "$numStaticTypeAnnotations");
453 return true; 460 return true;
454 } 461 }
455 return false; 462 return false;
456 } else if (errors.length != 0) { 463 } else if (errors.length != 0) {
457 return true; 464 return true;
458 } 465 }
459 return false; 466 return false;
460 } 467 }
461 468
462 // Parse a line delimited by the | character using \ as an escape charager 469 // Parse a line delimited by the | character using \ as an escape charager
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 line = source.readLine(); 593 line = source.readLine();
587 } 594 }
588 }; 595 };
589 } 596 }
590 597
591 void start() { 598 void start() {
592 Expect.isFalse(testCase.expectedOutcomes.contains(SKIP)); 599 Expect.isFalse(testCase.expectedOutcomes.contains(SKIP));
593 stdout = new List<String>(); 600 stdout = new List<String>();
594 stderr = new List<String>(); 601 stderr = new List<String>();
595 currentStep = 0; 602 currentStep = 0;
603 startTime = new Date.now();
596 runCommand(testCase.commands[currentStep++], stepExitHandler); 604 runCommand(testCase.commands[currentStep++], stepExitHandler);
597 } 605 }
598 606
599 void runCommand(Command command, 607 void runCommand(Command command,
600 void exitHandler(int exitCode)) { 608 void exitHandler(int exitCode)) {
601 if (Platform.operatingSystem == 'windows') { 609 if (Platform.operatingSystem == 'windows') {
602 // Windows can't handle the first command if it is a .bat file or the like 610 // Windows can't handle the first command if it is a .bat file or the like
603 // with the slashes going the other direction. 611 // with the slashes going the other direction.
604 // TODO(efortuna): Remove this when fixed (Issue 1306). 612 // TODO(efortuna): Remove this when fixed (Issue 1306).
605 command.executable = command.executable.replaceAll('/', '\\'); 613 command.executable = command.executable.replaceAll('/', '\\');
606 } 614 }
607 process = Process.start(command.executable, command.arguments); 615 process = Process.start(command.executable, command.arguments);
608 process.onExit = exitHandler; 616 process.onExit = exitHandler;
609 process.onError = (e) { 617 process.onError = (e) {
610 print("Error starting process:"); 618 print("Error starting process:");
611 print(" Command: $command"); 619 print(" Command: $command");
612 print(" Error: $e"); 620 print(" Error: $e");
613 }; 621 };
614 startTime = new Date.now();
615 InputStream stdoutStream = process.stdout; 622 InputStream stdoutStream = process.stdout;
616 InputStream stderrStream = process.stderr; 623 InputStream stderrStream = process.stderr;
617 StringInputStream stdoutStringStream = new StringInputStream(stdoutStream); 624 StringInputStream stdoutStringStream = new StringInputStream(stdoutStream);
618 StringInputStream stderrStringStream = new StringInputStream(stderrStream); 625 StringInputStream stderrStringStream = new StringInputStream(stderrStream);
619 stdoutStringStream.onLine = 626 stdoutStringStream.onLine =
620 makeReadHandler(stdoutStringStream, stdout); 627 makeReadHandler(stdoutStringStream, stdout);
621 stderrStringStream.onLine = 628 stderrStringStream.onLine =
622 makeReadHandler(stderrStringStream, stderr); 629 makeReadHandler(stderrStringStream, stderr);
623 if (timeoutTimer == null) { 630 if (timeoutTimer == null) {
624 // Create one timeout timer when starting test case, remove it at end. 631 // Create one timeout timer when starting test case, remove it at end.
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 test.completed(); 735 test.completed();
729 } 736 }
730 737
731 int _reportResult(String output) { 738 int _reportResult(String output) {
732 _stdoutDrained = true; 739 _stdoutDrained = true;
733 // output = '>>> TEST {PASS, FAIL, OK, CRASH, FAIL, TIMEOUT}' 740 // output = '>>> TEST {PASS, FAIL, OK, CRASH, FAIL, TIMEOUT}'
734 var outcome = output.split(" ")[2]; 741 var outcome = output.split(" ")[2];
735 var exitCode = 0; 742 var exitCode = 0;
736 if (outcome == "CRASH") exitCode = -10; 743 if (outcome == "CRASH") exitCode = -10;
737 if (outcome == "FAIL" || outcome == "TIMEOUT") exitCode = 1; 744 if (outcome == "FAIL" || outcome == "TIMEOUT") exitCode = 1;
738 new TestOutput.fromCase(_currentTest, exitCode, outcome == "TIMEOUT", 745 new TestOutput.fromCase(_currentTest, exitCode, (outcome == "TIMEOUT"),
739 _testStdout, _testStderr, new Date.now().difference(_startTim e)); 746 _testStdout, _testStderr,
747 new Date.now().difference(_startTime));
740 // Move on when both stdout and stderr has been drained. If the test 748 // Move on when both stdout and stderr has been drained. If the test
741 // crashed, we restarted the process and therefore do not attempt to 749 // crashed, we restarted the process and therefore do not attempt to
742 // drain stderr. 750 // drain stderr.
743 if (_stderrDrained || (_currentTest.output.hasCrashed)) _testCompleted(); 751 if (_stderrDrained || (_currentTest.output.hasCrashed)) _testCompleted();
744 } 752 }
745 753
746 void _stderrDone() { 754 void _stderrDone() {
747 _stderrDrained = true; 755 _stderrDrained = true;
748 // Move on when both stdout and stderr has been drained. 756 // Move on when both stdout and stderr has been drained.
749 if (_stdoutDrained) _testCompleted(); 757 if (_stdoutDrained) _testCompleted();
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 // the developer doesn't waste his or her time trying to fix a bunch of 1168 // the developer doesn't waste his or her time trying to fix a bunch of
1161 // tests that appear to be broken but were actually just flakes that 1169 // tests that appear to be broken but were actually just flakes that
1162 // didn't get retried because there had already been one failure. 1170 // didn't get retried because there had already been one failure.
1163 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests; 1171 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests;
1164 new RunningProcess(test, allowRetry, this).start(); 1172 new RunningProcess(test, allowRetry, this).start();
1165 } 1173 }
1166 _numProcesses++; 1174 _numProcesses++;
1167 } 1175 }
1168 } 1176 }
1169 } 1177 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698