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

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: 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
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 /**
(...skipping 25 matching lines...) Expand all
36 } 36 }
37 } 37 }
38 Expect.fail("Cound not find the Dart shell executable."); 38 Expect.fail("Cound not find the Dart shell executable.");
39 } 39 }
40 40
41 41
42 class TestCase { 42 class TestCase {
43 String executablePath; 43 String executablePath;
44 List<String> arguments; 44 List<String> arguments;
45 String commandLine; 45 String commandLine;
46 String displayName;
46 TestOutput output; 47 TestOutput output;
47 Set<String> expectedOutcomes; 48 Set<String> expectedOutcomes;
48 Function completedHandler; 49 Function completedHandler;
49 50
50 TestCase(this.executablePath, this.arguments, 51 TestCase(this.displayName, this.executablePath, this.arguments,
51 this.completedHandler, this.expectedOutcomes) { 52 this.completedHandler, this.expectedOutcomes) {
52 commandLine = executablePath; 53 commandLine = executablePath;
53 for (var arg in arguments) { 54 for (var arg in arguments) {
54 commandLine += " " + arg; 55 commandLine += " " + arg;
55 } 56 }
56 } 57 }
57 58
58 bool get isNegative() => false; 59 bool get isNegative() => false;
59 60
60 void completed() { completedHandler(this); } 61 void completed() { completedHandler(this); }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 timeoutTimer = new Timer(timeoutHandler, 1000 * timeout, false); 148 timeoutTimer = new Timer(timeoutHandler, 1000 * timeout, false);
148 } 149 }
149 } 150 }
150 151
151 void timeoutHandler(Timer unusedTimer) { 152 void timeoutHandler(Timer unusedTimer) {
152 timedOut = true; 153 timedOut = true;
153 process.kill(); 154 process.kill();
154 } 155 }
155 } 156 }
156 157
158
159 class ProcessQueue {
160 int numProcesses = 0;
161 final int maxProcesses = 4;
Mads Ager (google) 2011/11/08 08:26:06 Let's do this right and take this as an argument?
162 Queue<TestCase> tests;
163
164 ProcessQueue(this.tests);
165
166 runTests() {
167 print(" ***");
Mads Ager (google) 2011/11/08 08:26:06 Remove.
Bill Hesse 2011/11/08 14:38:56 Done.
168 while (numProcesses < maxProcesses && !tests.isEmpty()) {
169 TestCase test = tests.removeFirst();
170 print("running ${test.displayName}");
Mads Ager (google) 2011/11/08 08:26:06 Add a TODO here to refactor this into various test
Bill Hesse 2011/11/08 14:38:56 Done.
171 Function old_callback = test.completedHandler;
Mads Ager (google) 2011/11/08 08:26:06 Why do you extract old_callback here? Why not just
Bill Hesse 2011/11/08 14:38:56 I think that won't work. We will call the current
172 Function wrapper = (TestCase test_arg) {
173 numProcesses--;
174 print("finished ${test_arg.displayName}");
175 runTests();
176 old_callback(test_arg);
177 };
178 test.completedHandler = wrapper;
179
180 new RunningProcess(test, 60).start();
Mads Ager (google) 2011/11/08 08:26:06 Add TODO here to take the actual timeout informati
Bill Hesse 2011/11/08 14:38:56 Done.
181 numProcesses++;
182 }
183 }
184 }
185
186
187 class AsyncProcessQueue {
Mads Ager (google) 2011/11/08 08:26:06 Let's switch the names. This should be the Process
Bill Hesse 2011/11/08 14:38:56 Only Async version provided, called ProcessQueue.
188 int numProcesses = 0;
189 final int maxProcesses = 4;
Mads Ager (google) 2011/11/08 08:26:06 Let's pass in the actual number of processors?
Bill Hesse 2011/11/08 14:38:56 Done.
190 Queue<TestCase> tests;
191
192 AsyncProcessQueue() : tests = new Queue<TestCase>();
193
194 runTests() {
195 print(" ***");
Mads Ager (google) 2011/11/08 08:26:06 Remove.
Bill Hesse 2011/11/08 14:38:56 Done.
196 while (numProcesses < maxProcesses && !tests.isEmpty()) {
Mads Ager (google) 2011/11/08 08:26:06 I don't think you need the while loop here. You ar
Bill Hesse 2011/11/08 14:38:56 Done.
197 TestCase test = tests.removeFirst();
198 print("running ${test.displayName}");
199 Function old_callback = test.completedHandler;
200 Function wrapper = (TestCase test_arg) {
201 numProcesses--;
202 print("finished ${test_arg.displayName}");
203 runTests();
204 old_callback(test_arg);
205 };
206 test.completedHandler = wrapper;
207
208 new RunningProcess(test, 60).start();
209 numProcesses++;
210 }
211 }
212
213 runTest(TestCase test) {
214 tests.add(test);
215 runTests();
216 }
217
218 }
219
OLDNEW
« tools/testing/dart/test_controller.dart ('K') | « tools/testing/dart/test_controller.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698