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

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

Issue 8492013: Add asynchronous test suite runner to Dart rewrite of test scripts. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Respond to more comments. Created 9 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
« no previous file with comments | « tools/test.dart ('k') | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 #library("test_runner"); 5 #library("test_runner");
6 6
7 7
8 #import("status_file_parser.dart"); 8 #import("status_file_parser.dart");
9 9
10 /** 10 /**
11 * Classes and methods for executing tests. 11 * Classes and methods for executing tests.
12 * 12 *
13 * This module includes: 13 * This module includes:
14 * - Managing parallel execution of tests, including timeout checks. 14 * - Managing parallel execution of tests, including timeout checks.
15 * - Evaluating the output of each test as pass/fail/crash/timeout. 15 * - Evaluating the output of each test as pass/fail/crash/timeout.
16 */ 16 */
17 17
18 // Possible outcomes of running a test. 18 // Possible outcomes of running a test.
19 final CRASH = "Crash"; 19 final CRASH = "Crash";
20 final TIMEOUT = "Timeout"; 20 final TIMEOUT = "Timeout";
21 final FAIL = "Fail"; 21 final FAIL = "Fail";
22 final PASS = "Pass"; 22 final PASS = "Pass";
23 // An indication to skip the test. The caller is responsible for skipping it. 23 // An indication to skip the test. The caller is responsible for skipping it.
24 final SKIP = "Skip"; 24 final SKIP = "Skip";
25 25
26 final int NO_TIMEOUT = 0;
27
26 String getDartShellFileName() { 28 String getDartShellFileName() {
27 var names = ["out/Debug_ia32/dart_bin", 29 var names = ["out/Debug_ia32/dart_bin",
28 "out/Release_ia32/dart_bin", 30 "out/Release_ia32/dart_bin",
29 "xcodebuild/Debug_ia32/dart_bin", 31 "xcodebuild/Debug_ia32/dart_bin",
30 "xcodebuild/Release_ia32/dart_bin", 32 "xcodebuild/Release_ia32/dart_bin",
31 "Debug_ia32/dart_bin.exe", 33 "Debug_ia32/dart_bin.exe",
32 "Release_ia32/dart_bin.exe"]; 34 "Release_ia32/dart_bin.exe"];
33 for (var name in names) { 35 for (var name in names) {
34 if (new File(name).existsSync()) { 36 if (new File(name).existsSync()) {
35 return name; 37 return name;
36 } 38 }
37 } 39 }
38 Expect.fail("Cound not find the Dart shell executable."); 40 Expect.fail("Cound not find the Dart shell executable.");
39 } 41 }
40 42
41 43
42 class TestCase { 44 class TestCase {
43 String executablePath; 45 String executablePath;
44 List<String> arguments; 46 List<String> arguments;
45 String commandLine; 47 String commandLine;
48 String displayName;
46 TestOutput output; 49 TestOutput output;
47 Set<String> expectedOutcomes; 50 Set<String> expectedOutcomes;
48 Function completedHandler; 51 Function completedHandler;
49 52
50 TestCase(this.executablePath, this.arguments, 53 TestCase(this.displayName, this.executablePath, this.arguments,
51 this.completedHandler, this.expectedOutcomes) { 54 this.completedHandler, this.expectedOutcomes) {
52 commandLine = executablePath; 55 commandLine = executablePath;
53 for (var arg in arguments) { 56 for (var arg in arguments) {
54 commandLine += " " + arg; 57 commandLine += " " + arg;
55 } 58 }
56 } 59 }
57 60
58 bool get isNegative() => false; 61 bool get isNegative() => false;
59 62
60 void completed() { completedHandler(this); } 63 void completed() { completedHandler(this); }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 Process process; 99 Process process;
97 TestCase testCase; 100 TestCase testCase;
98 int timeout; 101 int timeout;
99 bool timedOut = false; 102 bool timedOut = false;
100 Date startTime; 103 Date startTime;
101 Timer timeoutTimer; 104 Timer timeoutTimer;
102 List<String> stdout; 105 List<String> stdout;
103 List<String> stderr; 106 List<String> stderr;
104 List<Function> handlers; 107 List<Function> handlers;
105 108
106 static final int NO_TIMEOUT = 0;
107 109
108 RunningProcess(this.testCase, [this.timeout = NO_TIMEOUT]); 110 RunningProcess(this.testCase, [this.timeout = NO_TIMEOUT]);
109 111
110 void exitHandler(int exitCode) { 112 void exitHandler(int exitCode) {
111 new TestOutput(testCase, exitCode, timedOut, stdout, 113 new TestOutput(testCase, exitCode, timedOut, stdout,
112 stderr, new Date.now().difference(startTime)); 114 stderr, new Date.now().difference(startTime));
113 process.close(); 115 process.close();
114 timeoutTimer.cancel(); 116 timeoutTimer.cancel();
115 testCase.completed(); 117 testCase.completed();
116 } 118 }
(...skipping 30 matching lines...) Expand all
147 timeoutTimer = new Timer(timeoutHandler, 1000 * timeout, false); 149 timeoutTimer = new Timer(timeoutHandler, 1000 * timeout, false);
148 } 150 }
149 } 151 }
150 152
151 void timeoutHandler(Timer unusedTimer) { 153 void timeoutHandler(Timer unusedTimer) {
152 timedOut = true; 154 timedOut = true;
153 process.kill(); 155 process.kill();
154 } 156 }
155 } 157 }
156 158
159
160 class ProcessQueue {
161 int numProcesses = 0;
162 final int maxProcesses;
163 Queue<TestCase> tests;
164
165 ProcessQueue(this.maxProcesses) : tests = new Queue<TestCase>();
166
167 tryRunTest() {
168 if (numProcesses < maxProcesses && !tests.isEmpty()) {
169 TestCase test = tests.removeFirst();
170 print("running ${test.displayName}");
171 // TODO(whesse): Refactor into various test output methods.
172 Function old_callback = test.completedHandler;
173 Function wrapper = (TestCase test_arg) {
174 numProcesses--;
175 print("finished ${test_arg.displayName}");
176 tryRunTest();
177 old_callback(test_arg);
178 };
179 test.completedHandler = wrapper;
180
181 // TODO(whesse): Add timeout information to TestCase, use it here.
182 new RunningProcess(test, 60).start();
183 numProcesses++;
184 }
185 }
186
187 runTest(TestCase test) {
188 tests.add(test);
189 tryRunTest();
190 }
191 }
OLDNEW
« no previous file with comments | « tools/test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698