Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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(""" |
| 435 Cannot have both @static-clean and /// static type warning annotations."""); | |
|
Mads Ager (google)
2012/05/14 12:20:16
Why not just split the line and use string concate
| |
| 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 |
|
Mads Ager (google)
2012/05/14 12:20:16
Space after //
| |
| 443 // intended so don't return failed. | 449 // intended so don't return failed. |
| 444 diagnostics.add("Fewer compile time errors than annotated: ${numCompileTim eAnnotations}"); | 450 diagnostics.add(""" |
| 451 Fewer compile time errors than annotated: ${numCompileTimeAnnotations}"""); | |
| 445 return false; | 452 return false; |
| 446 } | 453 } |
| 447 | 454 |
| 448 if (numStaticTypeAnnotations > 0 || hasFatalTypeErrors) { | 455 if (numStaticTypeAnnotations > 0 || hasFatalTypeErrors) { |
| 449 // TODO(zundel): match up the annotation line numbers | 456 // TODO(zundel): match up the annotation line numbers |
| 450 // with the reported error line numbers | 457 // with the reported error line numbers |
| 451 if (staticWarnings.length < numStaticTypeAnnotations) { | 458 if (staticWarnings.length < numStaticTypeAnnotations) { |
| 452 diagnostics.add("Fewer static type warnings than annotated: ${numStaticT ypeAnnotations}"); | 459 diagnostics.add(""" |
| 460 Fewer static type warnings than annotated: ${numStaticTypeAnnotations}"""); | |
| 453 return true; | 461 return true; |
| 454 } | 462 } |
| 455 return false; | 463 return false; |
| 456 } else if (errors.length != 0) { | 464 } else if (errors.length != 0) { |
| 457 return true; | 465 return true; |
| 458 } | 466 } |
| 459 return false; | 467 return false; |
| 460 } | 468 } |
| 461 | 469 |
| 462 // Parse a line delimited by the | character using \ as an escape charager | 470 // Parse a line delimited by the | character using \ as an escape charager |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 586 line = source.readLine(); | 594 line = source.readLine(); |
| 587 } | 595 } |
| 588 }; | 596 }; |
| 589 } | 597 } |
| 590 | 598 |
| 591 void start() { | 599 void start() { |
| 592 Expect.isFalse(testCase.expectedOutcomes.contains(SKIP)); | 600 Expect.isFalse(testCase.expectedOutcomes.contains(SKIP)); |
| 593 stdout = new List<String>(); | 601 stdout = new List<String>(); |
| 594 stderr = new List<String>(); | 602 stderr = new List<String>(); |
| 595 currentStep = 0; | 603 currentStep = 0; |
| 604 startTime = new Date.now(); | |
| 596 runCommand(testCase.commands[currentStep++], stepExitHandler); | 605 runCommand(testCase.commands[currentStep++], stepExitHandler); |
| 597 } | 606 } |
| 598 | 607 |
| 599 void runCommand(Command command, | 608 void runCommand(Command command, |
| 600 void exitHandler(int exitCode)) { | 609 void exitHandler(int exitCode)) { |
| 601 if (Platform.operatingSystem == 'windows') { | 610 if (Platform.operatingSystem == 'windows') { |
| 602 // Windows can't handle the first command if it is a .bat file or the like | 611 // Windows can't handle the first command if it is a .bat file or the like |
| 603 // with the slashes going the other direction. | 612 // with the slashes going the other direction. |
| 604 // TODO(efortuna): Remove this when fixed (Issue 1306). | 613 // TODO(efortuna): Remove this when fixed (Issue 1306). |
| 605 command.executable = command.executable.replaceAll('/', '\\'); | 614 command.executable = command.executable.replaceAll('/', '\\'); |
| 606 } | 615 } |
| 607 process = Process.start(command.executable, command.arguments); | 616 process = Process.start(command.executable, command.arguments); |
| 608 process.onExit = exitHandler; | 617 process.onExit = exitHandler; |
| 609 process.onError = (e) { | 618 process.onError = (e) { |
| 610 print("Error starting process:"); | 619 print("Error starting process:"); |
| 611 print(" Command: $command"); | 620 print(" Command: $command"); |
| 612 print(" Error: $e"); | 621 print(" Error: $e"); |
| 613 }; | 622 }; |
| 614 startTime = new Date.now(); | |
| 615 InputStream stdoutStream = process.stdout; | 623 InputStream stdoutStream = process.stdout; |
| 616 InputStream stderrStream = process.stderr; | 624 InputStream stderrStream = process.stderr; |
| 617 StringInputStream stdoutStringStream = new StringInputStream(stdoutStream); | 625 StringInputStream stdoutStringStream = new StringInputStream(stdoutStream); |
| 618 StringInputStream stderrStringStream = new StringInputStream(stderrStream); | 626 StringInputStream stderrStringStream = new StringInputStream(stderrStream); |
| 619 stdoutStringStream.onLine = | 627 stdoutStringStream.onLine = |
| 620 makeReadHandler(stdoutStringStream, stdout); | 628 makeReadHandler(stdoutStringStream, stdout); |
| 621 stderrStringStream.onLine = | 629 stderrStringStream.onLine = |
| 622 makeReadHandler(stderrStringStream, stderr); | 630 makeReadHandler(stderrStringStream, stderr); |
| 623 if (timeoutTimer == null) { | 631 if (timeoutTimer == null) { |
| 624 // Create one timeout timer when starting test case, remove it at end. | 632 // Create one timeout timer when starting test case, remove it at end. |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 728 test.completed(); | 736 test.completed(); |
| 729 } | 737 } |
| 730 | 738 |
| 731 int _reportResult(String output) { | 739 int _reportResult(String output) { |
| 732 _stdoutDrained = true; | 740 _stdoutDrained = true; |
| 733 // output = '>>> TEST {PASS, FAIL, OK, CRASH, FAIL, TIMEOUT}' | 741 // output = '>>> TEST {PASS, FAIL, OK, CRASH, FAIL, TIMEOUT}' |
| 734 var outcome = output.split(" ")[2]; | 742 var outcome = output.split(" ")[2]; |
| 735 var exitCode = 0; | 743 var exitCode = 0; |
| 736 if (outcome == "CRASH") exitCode = -10; | 744 if (outcome == "CRASH") exitCode = -10; |
| 737 if (outcome == "FAIL" || outcome == "TIMEOUT") exitCode = 1; | 745 if (outcome == "FAIL" || outcome == "TIMEOUT") exitCode = 1; |
| 738 new TestOutput.fromCase(_currentTest, exitCode, outcome == "TIMEOUT", | 746 new TestOutput.fromCase(_currentTest, exitCode, (outcome == "TIMEOUT"), |
| 739 _testStdout, _testStderr, new Date.now().difference(_startTim e)); | 747 _testStdout, _testStderr, |
| 748 new Date.now().difference(_startTime)); | |
| 740 // Move on when both stdout and stderr has been drained. If the test | 749 // 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 | 750 // crashed, we restarted the process and therefore do not attempt to |
| 742 // drain stderr. | 751 // drain stderr. |
| 743 if (_stderrDrained || (_currentTest.output.hasCrashed)) _testCompleted(); | 752 if (_stderrDrained || (_currentTest.output.hasCrashed)) _testCompleted(); |
| 744 } | 753 } |
| 745 | 754 |
| 746 void _stderrDone() { | 755 void _stderrDone() { |
| 747 _stderrDrained = true; | 756 _stderrDrained = true; |
| 748 // Move on when both stdout and stderr has been drained. | 757 // Move on when both stdout and stderr has been drained. |
| 749 if (_stdoutDrained) _testCompleted(); | 758 if (_stdoutDrained) _testCompleted(); |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1160 // the developer doesn't waste his or her time trying to fix a bunch of | 1169 // 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 | 1170 // tests that appear to be broken but were actually just flakes that |
| 1162 // didn't get retried because there had already been one failure. | 1171 // didn't get retried because there had already been one failure. |
| 1163 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests; | 1172 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests; |
| 1164 new RunningProcess(test, allowRetry, this).start(); | 1173 new RunningProcess(test, allowRetry, this).start(); |
| 1165 } | 1174 } |
| 1166 _numProcesses++; | 1175 _numProcesses++; |
| 1167 } | 1176 } |
| 1168 } | 1177 } |
| 1169 } | 1178 } |
| OLD | NEW |