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

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

Issue 2434123003: Merge more Kernel infrastructure from kernel_sdk SDK fork. (Closed)
Patch Set: Created 4 years, 2 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
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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
238 class KernelTransformationCommand extends CompilationCommand {
239 final bool useBatchMode;
240
241 KernelTransformationCommand._(
242 String displayName,
243 String outputFile,
244 bool neverSkipCompilation,
245 List<Uri> bootstrapDependencies,
246 String executable,
247 List<String> arguments,
248 Map<String, String> environmentOverrides,
249 this.useBatchMode)
250 : super._(displayName, outputFile, neverSkipCompilation,
251 bootstrapDependencies, executable, arguments,
252 environmentOverrides);
Bill Hesse 2016/10/21 12:17:39 Override operator == to include useBatchMode?
Vyacheslav Egorov (Google) 2016/10/21 13:39:44 I removed this class because it is not used anymor
253 }
254
255
224 /// This is just a Pair(String, Map) class with hashCode and operator == 256 /// This is just a Pair(String, Map) class with hashCode and operator ==
225 class AddFlagsKey { 257 class AddFlagsKey {
226 final String flags; 258 final String flags;
227 final Map env; 259 final Map env;
228 AddFlagsKey(this.flags, this.env); 260 AddFlagsKey(this.flags, this.env);
229 // Just use object identity for environment map 261 // Just use object identity for environment map
230 bool operator ==(other) => 262 bool operator ==(other) =>
231 other is AddFlagsKey && flags == other.flags && env == other.env; 263 other is AddFlagsKey && flags == other.flags && env == other.env;
232 int get hashCode => flags.hashCode ^ env.hashCode; 264 int get hashCode => flags.hashCode ^ env.hashCode;
233 } 265 }
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 displayName, 675 displayName,
644 outputFile, 676 outputFile,
645 neverSkipCompilation, 677 neverSkipCompilation,
646 bootstrapDependencies, 678 bootstrapDependencies,
647 executable, 679 executable,
648 arguments, 680 arguments,
649 environment); 681 environment);
650 return _getUniqueCommand(command); 682 return _getUniqueCommand(command);
651 } 683 }
652 684
685 CompilationCommand getKernelCompilationCommand(
686 String displayName,
687 outputFile,
688 neverSkipCompilation,
689 List<Uri> bootstrapDependencies,
690 String executable,
691 List<String> arguments,
692 Map<String, String> environment) {
693 var command = new KernelCompilationCommand._(
694 displayName,
695 outputFile,
696 neverSkipCompilation,
697 bootstrapDependencies,
698 executable,
699 arguments,
700 environment);
701 return _getUniqueCommand(command);
702 }
703
704 CompilationCommand getKernelTransformationCommand(
705 String transformation,
706 String executable,
707 List<String> arguments,
708 String outputFile,
709 Map<String, String> environment,
710 bool useBatchMode) {
711 var command = new KernelTransformationCommand._(
712 "kernel_transformation_$transformation",
713 outputFile,
714 false,
715 const [],
716 executable,
717 arguments,
718 environment,
719 useBatchMode);
720 return _getUniqueCommand(command);
721 }
722
723
653 AnalysisCommand getAnalysisCommand( 724 AnalysisCommand getAnalysisCommand(
654 String displayName, executable, arguments, environmentOverrides, 725 String displayName, executable, arguments, environmentOverrides,
655 {String flavor: 'dart2analyzer'}) { 726 {String flavor: 'dart2analyzer'}) {
656 var command = new AnalysisCommand._( 727 var command = new AnalysisCommand._(
657 flavor, displayName, executable, arguments, environmentOverrides); 728 flavor, displayName, executable, arguments, environmentOverrides);
658 return _getUniqueCommand(command); 729 return _getUniqueCommand(command);
659 } 730 }
660 731
661 VmCommand getVmCommand(String executable, List<String> arguments, 732 VmCommand getVmCommand(String executable, List<String> arguments,
662 Map<String, String> environmentOverrides) { 733 Map<String, String> environmentOverrides) {
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 assert(exitCode != 0); 1673 assert(exitCode != 0);
1603 return Expectation.COMPILETIME_ERROR; 1674 return Expectation.COMPILETIME_ERROR;
1604 } 1675 }
1605 1676
1606 Expectation outcome = 1677 Expectation outcome =
1607 exitCode == 0 ? Expectation.PASS : Expectation.COMPILETIME_ERROR; 1678 exitCode == 0 ? Expectation.PASS : Expectation.COMPILETIME_ERROR;
1608 return _negateOutcomeIfNegativeTest(outcome, testCase.isNegative); 1679 return _negateOutcomeIfNegativeTest(outcome, testCase.isNegative);
1609 } 1680 }
1610 } 1681 }
1611 1682
1683 class KernelCompilationCommandOutputImpl extends CompilationCommandOutputImpl {
1684 KernelCompilationCommandOutputImpl(
1685 Command command, int exitCode, bool timedOut,
1686 List<int> stdout, List<int> stderr,
1687 Duration time, bool compilationSkipped)
1688 : super(command, exitCode, timedOut, stdout, stderr, time,
1689 compilationSkipped);
1690
1691 bool get canRunDependendCommands {
1692 // See [BatchRunnerProcess]: 0 means success, 1 means compile-time error.
1693 // TODO(asgerf): When the frontend supports it, continue running even if
1694 // there were compile-time errors. See kernel_sdk issue #18.
1695 return !hasCrashed && !timedOut && exitCode == 0;
1696 }
1697
1698 // If the compiler was able to produce a Kernel IR file we want to run the
1699 // result on the Dart VM. We therefore mark the [KernelCompilationCommand] as
1700 // successful.
1701 // => This ensures we test that the DartVM produces correct CompileTime errors
1702 // as it is supposed to for our test suites.
1703 bool get successful => canRunDependendCommands;
1704 }
1705
1706 class KernelTransformationCommandOutputImpl extends CompilationCommandOutputImpl {
1707 KernelTransformationCommandOutputImpl(
1708 Command command, int exitCode, bool timedOut,
1709 List<int> stdout, List<int> stderr,
1710 Duration time, bool compilationSkipped)
1711 : super(command, exitCode, timedOut, stdout, stderr, time,
1712 compilationSkipped);
1713
1714 bool get canRunDependendCommands {
1715 return !hasCrashed && !timedOut && exitCode == 0;
1716 }
1717
1718 bool get successful => canRunDependendCommands;
1719 }
1720
1612 class JsCommandlineOutputImpl extends CommandOutputImpl 1721 class JsCommandlineOutputImpl extends CommandOutputImpl
1613 with UnittestSuiteMessagesMixin { 1722 with UnittestSuiteMessagesMixin {
1614 JsCommandlineOutputImpl(Command command, int exitCode, bool timedOut, 1723 JsCommandlineOutputImpl(Command command, int exitCode, bool timedOut,
1615 List<int> stdout, List<int> stderr, Duration time) 1724 List<int> stdout, List<int> stderr, Duration time)
1616 : super(command, exitCode, timedOut, stdout, stderr, time, false, 0); 1725 : super(command, exitCode, timedOut, stdout, stderr, time, false, 0);
1617 1726
1618 Expectation result(TestCase testCase) { 1727 Expectation result(TestCase testCase) {
1619 // Handle crashes and timeouts first 1728 // Handle crashes and timeouts first
1620 if (hasCrashed) return Expectation.CRASH; 1729 if (hasCrashed) return Expectation.CRASH;
1621 if (hasTimedOut) return Expectation.TIMEOUT; 1730 if (hasTimedOut) return Expectation.TIMEOUT;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1676 command, exitCode, timedOut, stdout, stderr, time, compilationSkipped); 1785 command, exitCode, timedOut, stdout, stderr, time, compilationSkipped);
1677 } else if (command is BrowserTestCommand) { 1786 } else if (command is BrowserTestCommand) {
1678 return new HTMLBrowserCommandOutputImpl( 1787 return new HTMLBrowserCommandOutputImpl(
1679 command, exitCode, timedOut, stdout, stderr, time, compilationSkipped); 1788 command, exitCode, timedOut, stdout, stderr, time, compilationSkipped);
1680 } else if (command is AnalysisCommand) { 1789 } else if (command is AnalysisCommand) {
1681 return new AnalysisCommandOutputImpl( 1790 return new AnalysisCommandOutputImpl(
1682 command, exitCode, timedOut, stdout, stderr, time, compilationSkipped); 1791 command, exitCode, timedOut, stdout, stderr, time, compilationSkipped);
1683 } else if (command is VmCommand) { 1792 } else if (command is VmCommand) {
1684 return new VmCommandOutputImpl( 1793 return new VmCommandOutputImpl(
1685 command, exitCode, timedOut, stdout, stderr, time, pid); 1794 command, exitCode, timedOut, stdout, stderr, time, pid);
1795 } else if (command is KernelCompilationCommand) {
1796 return new KernelCompilationCommandOutputImpl(
1797 command, exitCode, timedOut, stdout, stderr, time, compilationSkipped);
1798 } else if (command is KernelTransformationCommand) {
1799 return new KernelTransformationCommandOutputImpl(
1800 command, exitCode, timedOut, stdout, stderr, time, compilationSkipped);
1686 } else if (command is AdbPrecompilationCommand) { 1801 } else if (command is AdbPrecompilationCommand) {
1687 return new VmCommandOutputImpl( 1802 return new VmCommandOutputImpl(
1688 command, exitCode, timedOut, stdout, stderr, time, pid); 1803 command, exitCode, timedOut, stdout, stderr, time, pid);
1689 } else if (command is CompilationCommand) { 1804 } else if (command is CompilationCommand) {
1690 if (command.displayName == 'precompiler' || 1805 if (command.displayName == 'precompiler' ||
1691 command.displayName == 'dart2snapshot') { 1806 command.displayName == 'dart2snapshot') {
1692 return new VmCommandOutputImpl( 1807 return new VmCommandOutputImpl(
1693 command, exitCode, timedOut, stdout, stderr, time, pid); 1808 command, exitCode, timedOut, stdout, stderr, time, pid);
1694 } 1809 }
1695 return new CompilationCommandOutputImpl( 1810 return new CompilationCommandOutputImpl(
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
2542 } 2657 }
2543 return runCommand(command.maxNumRetries); 2658 return runCommand(command.maxNumRetries);
2544 } 2659 }
2545 2660
2546 Future<CommandOutput> _runCommand(Command command, int timeout) { 2661 Future<CommandOutput> _runCommand(Command command, int timeout) {
2547 var batchMode = !globalConfiguration['noBatch']; 2662 var batchMode = !globalConfiguration['noBatch'];
2548 var dart2jsBatchMode = globalConfiguration['dart2js_batch']; 2663 var dart2jsBatchMode = globalConfiguration['dart2js_batch'];
2549 2664
2550 if (command is BrowserTestCommand) { 2665 if (command is BrowserTestCommand) {
2551 return _startBrowserControllerTest(command, timeout); 2666 return _startBrowserControllerTest(command, timeout);
2667 } else if (command is KernelTransformationCommand) {
2668 if (command.useBatchMode) {
2669 // For now, we always run transform.dart in batch mode (if we can).
2670 var name = command.displayName;
2671 return _getBatchRunner(name)
2672 .runCommand(name, command, timeout, command.arguments);
2673 } else {
2674 return new RunningProcess(command, timeout).run();
2675 }
2676 } else if (command is KernelCompilationCommand) {
2677 // For now, we always run dartk in batch mode.
2678 var name = command.displayName;
2679 assert(name == 'dartk');
2680 return _getBatchRunner(name)
2681 .runCommand(name, command, timeout, command.arguments);
2552 } else if (command is CompilationCommand && dart2jsBatchMode) { 2682 } else if (command is CompilationCommand && dart2jsBatchMode) {
2553 return _getBatchRunner("dart2js") 2683 return _getBatchRunner("dart2js")
2554 .runCommand("dart2js", command, timeout, command.arguments); 2684 .runCommand("dart2js", command, timeout, command.arguments);
2555 } else if (command is AnalysisCommand && batchMode) { 2685 } else if (command is AnalysisCommand && batchMode) {
2556 return _getBatchRunner(command.flavor) 2686 return _getBatchRunner(command.flavor)
2557 .runCommand(command.flavor, command, timeout, command.arguments); 2687 .runCommand(command.flavor, command, timeout, command.arguments);
2558 } else if (command is ScriptCommand) { 2688 } else if (command is ScriptCommand) {
2559 return command.run(); 2689 return command.run();
2560 } else if (command is AdbPrecompilationCommand) { 2690 } else if (command is AdbPrecompilationCommand) {
2561 assert(adbDevicePool != null); 2691 assert(adbDevicePool != null);
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
3074 } 3204 }
3075 } 3205 }
3076 3206
3077 void eventAllTestsDone() { 3207 void eventAllTestsDone() {
3078 for (var listener in _eventListener) { 3208 for (var listener in _eventListener) {
3079 listener.allDone(); 3209 listener.allDone();
3080 } 3210 }
3081 _allDone(); 3211 _allDone();
3082 } 3212 }
3083 } 3213 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698