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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 builder.addJson(_bootstrapDependencies); | 214 builder.addJson(_bootstrapDependencies); |
215 } | 215 } |
216 | 216 |
217 bool _equal(CompilationCommand other) => | 217 bool _equal(CompilationCommand other) => |
218 super._equal(other) && | 218 super._equal(other) && |
219 _outputFile == other._outputFile && | 219 _outputFile == other._outputFile && |
220 _neverSkipCompilation == other._neverSkipCompilation && | 220 _neverSkipCompilation == other._neverSkipCompilation && |
221 deepJsonCompare(_bootstrapDependencies, other._bootstrapDependencies); | 221 deepJsonCompare(_bootstrapDependencies, other._bootstrapDependencies); |
222 } | 222 } |
223 | 223 |
| 224 class KernelCompilationCommand extends CompilationCommand { |
| 225 KernelCompilationCommand._( |
| 226 String displayName, |
| 227 String outputFile, |
| 228 bool neverSkipCompilation, |
| 229 List<Uri> bootstrapDependencies, |
| 230 String executable, |
| 231 List<String> arguments, |
| 232 Map<String, String> environmentOverrides) |
| 233 : super._(displayName, outputFile, neverSkipCompilation, |
| 234 bootstrapDependencies, executable, arguments, |
| 235 environmentOverrides); |
| 236 } |
| 237 |
224 /// This is just a Pair(String, Map) class with hashCode and operator == | 238 /// This is just a Pair(String, Map) class with hashCode and operator == |
225 class AddFlagsKey { | 239 class AddFlagsKey { |
226 final String flags; | 240 final String flags; |
227 final Map env; | 241 final Map env; |
228 AddFlagsKey(this.flags, this.env); | 242 AddFlagsKey(this.flags, this.env); |
229 // Just use object identity for environment map | 243 // Just use object identity for environment map |
230 bool operator ==(other) => | 244 bool operator ==(other) => |
231 other is AddFlagsKey && flags == other.flags && env == other.env; | 245 other is AddFlagsKey && flags == other.flags && env == other.env; |
232 int get hashCode => flags.hashCode ^ env.hashCode; | 246 int get hashCode => flags.hashCode ^ env.hashCode; |
233 } | 247 } |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 displayName, | 657 displayName, |
644 outputFile, | 658 outputFile, |
645 neverSkipCompilation, | 659 neverSkipCompilation, |
646 bootstrapDependencies, | 660 bootstrapDependencies, |
647 executable, | 661 executable, |
648 arguments, | 662 arguments, |
649 environment); | 663 environment); |
650 return _getUniqueCommand(command); | 664 return _getUniqueCommand(command); |
651 } | 665 } |
652 | 666 |
| 667 CompilationCommand getKernelCompilationCommand( |
| 668 String displayName, |
| 669 outputFile, |
| 670 neverSkipCompilation, |
| 671 List<Uri> bootstrapDependencies, |
| 672 String executable, |
| 673 List<String> arguments, |
| 674 Map<String, String> environment) { |
| 675 var command = new KernelCompilationCommand._( |
| 676 displayName, |
| 677 outputFile, |
| 678 neverSkipCompilation, |
| 679 bootstrapDependencies, |
| 680 executable, |
| 681 arguments, |
| 682 environment); |
| 683 return _getUniqueCommand(command); |
| 684 } |
| 685 |
653 AnalysisCommand getAnalysisCommand( | 686 AnalysisCommand getAnalysisCommand( |
654 String displayName, executable, arguments, environmentOverrides, | 687 String displayName, executable, arguments, environmentOverrides, |
655 {String flavor: 'dart2analyzer'}) { | 688 {String flavor: 'dart2analyzer'}) { |
656 var command = new AnalysisCommand._( | 689 var command = new AnalysisCommand._( |
657 flavor, displayName, executable, arguments, environmentOverrides); | 690 flavor, displayName, executable, arguments, environmentOverrides); |
658 return _getUniqueCommand(command); | 691 return _getUniqueCommand(command); |
659 } | 692 } |
660 | 693 |
661 VmCommand getVmCommand(String executable, List<String> arguments, | 694 VmCommand getVmCommand(String executable, List<String> arguments, |
662 Map<String, String> environmentOverrides) { | 695 Map<String, String> environmentOverrides) { |
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1602 assert(exitCode != 0); | 1635 assert(exitCode != 0); |
1603 return Expectation.COMPILETIME_ERROR; | 1636 return Expectation.COMPILETIME_ERROR; |
1604 } | 1637 } |
1605 | 1638 |
1606 Expectation outcome = | 1639 Expectation outcome = |
1607 exitCode == 0 ? Expectation.PASS : Expectation.COMPILETIME_ERROR; | 1640 exitCode == 0 ? Expectation.PASS : Expectation.COMPILETIME_ERROR; |
1608 return _negateOutcomeIfNegativeTest(outcome, testCase.isNegative); | 1641 return _negateOutcomeIfNegativeTest(outcome, testCase.isNegative); |
1609 } | 1642 } |
1610 } | 1643 } |
1611 | 1644 |
| 1645 class KernelCompilationCommandOutputImpl extends CompilationCommandOutputImpl { |
| 1646 KernelCompilationCommandOutputImpl( |
| 1647 Command command, int exitCode, bool timedOut, |
| 1648 List<int> stdout, List<int> stderr, |
| 1649 Duration time, bool compilationSkipped) |
| 1650 : super(command, exitCode, timedOut, stdout, stderr, time, |
| 1651 compilationSkipped); |
| 1652 |
| 1653 bool get canRunDependendCommands { |
| 1654 // See [BatchRunnerProcess]: 0 means success, 1 means compile-time error. |
| 1655 // TODO(asgerf): When the frontend supports it, continue running even if |
| 1656 // there were compile-time errors. See kernel_sdk issue #18. |
| 1657 return !hasCrashed && !timedOut && exitCode == 0; |
| 1658 } |
| 1659 |
| 1660 // If the compiler was able to produce a Kernel IR file we want to run the |
| 1661 // result on the Dart VM. We therefore mark the [KernelCompilationCommand] as |
| 1662 // successful. |
| 1663 // => This ensures we test that the DartVM produces correct CompileTime errors |
| 1664 // as it is supposed to for our test suites. |
| 1665 bool get successful => canRunDependendCommands; |
| 1666 } |
| 1667 |
1612 class JsCommandlineOutputImpl extends CommandOutputImpl | 1668 class JsCommandlineOutputImpl extends CommandOutputImpl |
1613 with UnittestSuiteMessagesMixin { | 1669 with UnittestSuiteMessagesMixin { |
1614 JsCommandlineOutputImpl(Command command, int exitCode, bool timedOut, | 1670 JsCommandlineOutputImpl(Command command, int exitCode, bool timedOut, |
1615 List<int> stdout, List<int> stderr, Duration time) | 1671 List<int> stdout, List<int> stderr, Duration time) |
1616 : super(command, exitCode, timedOut, stdout, stderr, time, false, 0); | 1672 : super(command, exitCode, timedOut, stdout, stderr, time, false, 0); |
1617 | 1673 |
1618 Expectation result(TestCase testCase) { | 1674 Expectation result(TestCase testCase) { |
1619 // Handle crashes and timeouts first | 1675 // Handle crashes and timeouts first |
1620 if (hasCrashed) return Expectation.CRASH; | 1676 if (hasCrashed) return Expectation.CRASH; |
1621 if (hasTimedOut) return Expectation.TIMEOUT; | 1677 if (hasTimedOut) return Expectation.TIMEOUT; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1676 command, exitCode, timedOut, stdout, stderr, time, compilationSkipped); | 1732 command, exitCode, timedOut, stdout, stderr, time, compilationSkipped); |
1677 } else if (command is BrowserTestCommand) { | 1733 } else if (command is BrowserTestCommand) { |
1678 return new HTMLBrowserCommandOutputImpl( | 1734 return new HTMLBrowserCommandOutputImpl( |
1679 command, exitCode, timedOut, stdout, stderr, time, compilationSkipped); | 1735 command, exitCode, timedOut, stdout, stderr, time, compilationSkipped); |
1680 } else if (command is AnalysisCommand) { | 1736 } else if (command is AnalysisCommand) { |
1681 return new AnalysisCommandOutputImpl( | 1737 return new AnalysisCommandOutputImpl( |
1682 command, exitCode, timedOut, stdout, stderr, time, compilationSkipped); | 1738 command, exitCode, timedOut, stdout, stderr, time, compilationSkipped); |
1683 } else if (command is VmCommand) { | 1739 } else if (command is VmCommand) { |
1684 return new VmCommandOutputImpl( | 1740 return new VmCommandOutputImpl( |
1685 command, exitCode, timedOut, stdout, stderr, time, pid); | 1741 command, exitCode, timedOut, stdout, stderr, time, pid); |
| 1742 } else if (command is KernelCompilationCommand) { |
| 1743 return new KernelCompilationCommandOutputImpl( |
| 1744 command, exitCode, timedOut, stdout, stderr, time, compilationSkipped); |
1686 } else if (command is AdbPrecompilationCommand) { | 1745 } else if (command is AdbPrecompilationCommand) { |
1687 return new VmCommandOutputImpl( | 1746 return new VmCommandOutputImpl( |
1688 command, exitCode, timedOut, stdout, stderr, time, pid); | 1747 command, exitCode, timedOut, stdout, stderr, time, pid); |
1689 } else if (command is CompilationCommand) { | 1748 } else if (command is CompilationCommand) { |
1690 if (command.displayName == 'precompiler' || | 1749 if (command.displayName == 'precompiler' || |
1691 command.displayName == 'dart2snapshot') { | 1750 command.displayName == 'dart2snapshot') { |
1692 return new VmCommandOutputImpl( | 1751 return new VmCommandOutputImpl( |
1693 command, exitCode, timedOut, stdout, stderr, time, pid); | 1752 command, exitCode, timedOut, stdout, stderr, time, pid); |
1694 } | 1753 } |
1695 return new CompilationCommandOutputImpl( | 1754 return new CompilationCommandOutputImpl( |
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2542 } | 2601 } |
2543 return runCommand(command.maxNumRetries); | 2602 return runCommand(command.maxNumRetries); |
2544 } | 2603 } |
2545 | 2604 |
2546 Future<CommandOutput> _runCommand(Command command, int timeout) { | 2605 Future<CommandOutput> _runCommand(Command command, int timeout) { |
2547 var batchMode = !globalConfiguration['noBatch']; | 2606 var batchMode = !globalConfiguration['noBatch']; |
2548 var dart2jsBatchMode = globalConfiguration['dart2js_batch']; | 2607 var dart2jsBatchMode = globalConfiguration['dart2js_batch']; |
2549 | 2608 |
2550 if (command is BrowserTestCommand) { | 2609 if (command is BrowserTestCommand) { |
2551 return _startBrowserControllerTest(command, timeout); | 2610 return _startBrowserControllerTest(command, timeout); |
| 2611 } else if (command is KernelCompilationCommand) { |
| 2612 // For now, we always run dartk in batch mode. |
| 2613 var name = command.displayName; |
| 2614 assert(name == 'dartk'); |
| 2615 return _getBatchRunner(name) |
| 2616 .runCommand(name, command, timeout, command.arguments); |
2552 } else if (command is CompilationCommand && dart2jsBatchMode) { | 2617 } else if (command is CompilationCommand && dart2jsBatchMode) { |
2553 return _getBatchRunner("dart2js") | 2618 return _getBatchRunner("dart2js") |
2554 .runCommand("dart2js", command, timeout, command.arguments); | 2619 .runCommand("dart2js", command, timeout, command.arguments); |
2555 } else if (command is AnalysisCommand && batchMode) { | 2620 } else if (command is AnalysisCommand && batchMode) { |
2556 return _getBatchRunner(command.flavor) | 2621 return _getBatchRunner(command.flavor) |
2557 .runCommand(command.flavor, command, timeout, command.arguments); | 2622 .runCommand(command.flavor, command, timeout, command.arguments); |
2558 } else if (command is ScriptCommand) { | 2623 } else if (command is ScriptCommand) { |
2559 return command.run(); | 2624 return command.run(); |
2560 } else if (command is AdbPrecompilationCommand) { | 2625 } else if (command is AdbPrecompilationCommand) { |
2561 assert(adbDevicePool != null); | 2626 assert(adbDevicePool != null); |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3074 } | 3139 } |
3075 } | 3140 } |
3076 | 3141 |
3077 void eventAllTestsDone() { | 3142 void eventAllTestsDone() { |
3078 for (var listener in _eventListener) { | 3143 for (var listener in _eventListener) { |
3079 listener.allDone(); | 3144 listener.allDone(); |
3080 } | 3145 } |
3081 _allDone(); | 3146 _allDone(); |
3082 } | 3147 } |
3083 } | 3148 } |
OLD | NEW |