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

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

Issue 11369216: Added support for skipping redundant dart2js compilations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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) 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.
11 */ 11 */
12 #library("test_runner"); 12 #library("test_runner");
13 13
14 #import("dart:io"); 14 #import("dart:io");
15 #import("dart:isolate"); 15 #import("dart:isolate");
16 #import("dart:uri");
16 #import("status_file_parser.dart"); 17 #import("status_file_parser.dart");
17 #import("test_progress.dart"); 18 #import("test_progress.dart");
18 #import("test_suite.dart"); 19 #import("test_suite.dart");
19 20
20 const int NO_TIMEOUT = 0; 21 const int NO_TIMEOUT = 0;
21 const int SLOW_TIMEOUT_MULTIPLIER = 4; 22 const int SLOW_TIMEOUT_MULTIPLIER = 4;
22 23
23 typedef void TestCaseEvent(TestCase testCase); 24 typedef void TestCaseEvent(TestCase testCase);
24 typedef void ExitCodeEvent(int exitCode); 25 typedef void ExitCodeEvent(int exitCode);
25 typedef void EnqueueMoreWork(ProcessQueue queue); 26 typedef void EnqueueMoreWork(ProcessQueue queue);
(...skipping 13 matching lines...) Expand all
39 if (Platform.operatingSystem == 'windows') { 40 if (Platform.operatingSystem == 'windows') {
40 // Windows can't handle the first command if it is a .bat file or the like 41 // Windows can't handle the first command if it is a .bat file or the like
41 // with the slashes going the other direction. 42 // with the slashes going the other direction.
42 // TODO(efortuna): Remove this when fixed (Issue 1306). 43 // TODO(efortuna): Remove this when fixed (Issue 1306).
43 executable = executable.replaceAll('/', '\\'); 44 executable = executable.replaceAll('/', '\\');
44 } 45 }
45 commandLine = "$executable ${Strings.join(arguments, ' ')}"; 46 commandLine = "$executable ${Strings.join(arguments, ' ')}";
46 } 47 }
47 48
48 String toString() => commandLine; 49 String toString() => commandLine;
50
51 bool get outputIsUpToDate => false;
52 }
53
54 class Dart2JsCommand extends Command {
55 String _jsOutFile;
ahe 2012/11/14 18:46:16 We try to avoid abbreviating. So this should be _
kustermann 2012/11/16 14:58:42 Done.
56 bool _neverSkipCompilation;
57 List<Uri> _bootstrapDeps;
ahe 2012/11/14 18:46:16 _bootstrapDependencies
kustermann 2012/11/16 14:58:42 Done.
58
59 Dart2JsCommand(String this._jsOutFile, bool this._neverSkipCompilation,
ricow1 2012/11/14 08:53:28 I know that not all of our code is actually strict
ahe 2012/11/14 18:46:16 Remove types from this.field parameters. They are
kustermann 2012/11/16 14:58:42 Done.
kustermann 2012/11/16 14:58:42 Done.
60 List<Uri> this._bootstrapDeps, String executable, List<String> arguments)
61 : super(executable, arguments);
62
63 bool get outputIsUpToDate {
64 if (_neverSkipCompilation) return false;
65
66 List<Uri> readDepsFile(String path) {
ricow1 2012/11/14 08:53:28 I think we should make this asynchronious
ahe 2012/11/14 18:46:16 Using the word "deps" file is fine in this case, b
kustermann 2012/11/16 14:58:42 Done.
67 var file = new File(path);
68 if (!file.existsSync()) {
69 return null;
70 }
71 var deps = new List<Uri>();
ahe 2012/11/14 18:46:16 But these are dependencies :-)
kustermann 2012/11/16 14:58:42 Done.
72 for (var line in file.readAsLinesSync()) {
73 line = line.trim();
74 if (line.length > 0) {
75 deps.add(new Uri(line));
76 }
77 }
78 return deps;
79 }
80
81 var deps = readDepsFile("$_jsOutFile.deps");
ahe 2012/11/14 18:46:16 dependencies
kustermann 2012/11/16 14:58:42 Done.
82 if (deps != null) {
83 deps.addAll(_bootstrapDeps);
84 var jsOutTimestamp = TestUtils.timestampCache.getTimeStamp(
ahe 2012/11/14 18:46:16 jsOutput...
kustermann 2012/11/16 14:58:42 Done.
85 new Uri("file://$_jsOutFile"));
ahe 2012/11/14 18:46:16 How do you ensure this is a valid file URI? See:
kustermann 2012/11/16 14:58:42 "StandardTestSuite.{makeCommands,_compileCommand}"
86 if (jsOutTimestamp != null) {
87 for (var dep in deps) {
88 var depTs = TestUtils.timestampCache.getTimeStamp(dep);
ahe 2012/11/14 18:46:16 In this case, abbreviation makes it really hard to
kustermann 2012/11/16 14:58:42 Done. But: Very often, longer names result in line
89 if (depTs == null || depTs > jsOutTimestamp) {
90 return false;
91 }
92 }
93 return true;
94 }
95 }
96 return false;
97 }
49 } 98 }
50 99
51 /** 100 /**
52 * TestCase contains all the information needed to run a test and evaluate 101 * TestCase contains all the information needed to run a test and evaluate
53 * its output. Running a test involves starting a separate process, with 102 * its output. Running a test involves starting a separate process, with
54 * the executable and arguments given by the TestCase, and recording its 103 * the executable and arguments given by the TestCase, and recording its
55 * stdout and stderr output streams, and its exit code. TestCase only 104 * stdout and stderr output streams, and its exit code. TestCase only
56 * contains static information about the test; actually running the test is 105 * contains static information about the test; actually running the test is
57 * performed by [ProcessQueue] using a [RunningProcess] object. 106 * performed by [ProcessQueue] using a [RunningProcess] object.
58 * 107 *
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 void start() { 748 void start() {
700 Expect.isFalse(testCase.expectedOutcomes.contains(SKIP)); 749 Expect.isFalse(testCase.expectedOutcomes.contains(SKIP));
701 stdout = new List<String>(); 750 stdout = new List<String>();
702 stderr = new List<String>(); 751 stderr = new List<String>();
703 currentStep = 0; 752 currentStep = 0;
704 startTime = new Date.now(); 753 startTime = new Date.now();
705 runCommand(testCase.commands[currentStep++], stepExitHandler); 754 runCommand(testCase.commands[currentStep++], stepExitHandler);
706 } 755 }
707 756
708 void runCommand(Command command, void exitHandler(int exitCode)) { 757 void runCommand(Command command, void exitHandler(int exitCode)) {
758 if (command.outputIsUpToDate) {
759 // NOTE: we need to have the same async + timeout handler behaviour as bel ow
ricow1 2012/11/14 08:53:28 long line
kustermann 2012/11/16 14:58:42 Done.
760 // otherwise we risk breaking code.
ahe 2012/11/14 18:46:16 Only one space after //.
kustermann 2012/11/16 14:58:42 Done.
761 timeoutTimer = new Timer(1000 * testCase.timeout, timeoutHandler);
762 new Timer(0, (ignored) {
ahe 2012/11/14 18:46:16 You could avoid this if command.outputIsUpToDate r
kustermann 2012/11/16 14:58:42 Done.
763 stdout.add("Skipped dart2js compilation because the old output is still up to date!");
ricow1 2012/11/14 08:53:28 long line
kustermann 2012/11/16 14:58:42 Done.
764 if (processQueue != null) {
Bill Hesse 2012/11/14 09:37:34 We don't ever get to this point without a processQ
kustermann 2012/11/16 14:58:42 Actually the test tests/standalone/io/test_runner
765 processQueue.logSkippedCompilation();
Bill Hesse 2012/11/14 09:37:34 Other information gets to the progress indicator b
kustermann 2012/11/16 14:58:42 Done.
766 }
767 exitHandler(0);
768 });
769 return;
770 }
771
709 Future processFuture = Process.start(command.executable, command.arguments); 772 Future processFuture = Process.start(command.executable, command.arguments);
710 processFuture.then((Process p) { 773 processFuture.then((Process p) {
711 process = p; 774 process = p;
712 process.onExit = exitHandler; 775 process.onExit = exitHandler;
713 var stdoutStringStream = new StringInputStream(process.stdout); 776 var stdoutStringStream = new StringInputStream(process.stdout);
714 var stderrStringStream = new StringInputStream(process.stderr); 777 var stderrStringStream = new StringInputStream(process.stderr);
715 stdoutStringStream.onLine = 778 stdoutStringStream.onLine =
716 makeReadHandler(stdoutStringStream, stdout); 779 makeReadHandler(stdoutStringStream, stdout);
717 stderrStringStream.onLine = 780 stderrStringStream.onLine =
718 makeReadHandler(stderrStringStream, stderr); 781 makeReadHandler(stderrStringStream, stderr);
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 } 1135 }
1073 1136
1074 /** 1137 /**
1075 * Registers a TestSuite so that all of its tests will be run. 1138 * Registers a TestSuite so that all of its tests will be run.
1076 */ 1139 */
1077 void addTestSuite(TestSuite testSuite) { 1140 void addTestSuite(TestSuite testSuite) {
1078 _activeTestListers++; 1141 _activeTestListers++;
1079 testSuite.forEachTest(_runTest, _testCache, _testListerDone); 1142 testSuite.forEachTest(_runTest, _testCache, _testListerDone);
1080 } 1143 }
1081 1144
1145 void logSkippedCompilation() {
1146 _progress.skippedCompilation();
1147 }
1148
1082 void _testListerDone() { 1149 void _testListerDone() {
1083 _activeTestListers--; 1150 _activeTestListers--;
1084 _checkDone(); 1151 _checkDone();
1085 } 1152 }
1086 1153
1087 /** 1154 /**
1088 * Perform any cleanup needed once all tests in a TestSuite have completed 1155 * Perform any cleanup needed once all tests in a TestSuite have completed
1089 * and notify our progress indicator that we are done. 1156 * and notify our progress indicator that we are done.
1090 */ 1157 */
1091 void _cleanupAndMarkDone() { 1158 void _cleanupAndMarkDone() {
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 // the developer doesn't waste his or her time trying to fix a bunch of 1397 // the developer doesn't waste his or her time trying to fix a bunch of
1331 // tests that appear to be broken but were actually just flakes that 1398 // tests that appear to be broken but were actually just flakes that
1332 // didn't get retried because there had already been one failure. 1399 // didn't get retried because there had already been one failure.
1333 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests; 1400 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests;
1334 new RunningProcess(test, allowRetry, this).start(); 1401 new RunningProcess(test, allowRetry, this).start();
1335 } 1402 }
1336 _numProcesses++; 1403 _numProcesses++;
1337 } 1404 }
1338 } 1405 }
1339 } 1406 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698