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

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

Issue 8682005: Perform better activity tracking in test scripts. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Hide more implementation details of ProcessQueue 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/testing/dart/test_progress.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 #import("status_file_parser.dart"); 7 #import("status_file_parser.dart");
8 #import("test_progress.dart"); 8 #import("test_progress.dart");
9 #import("test_suite.dart");
9 10
10 /** 11 /**
11 * Classes and methods for executing tests. 12 * Classes and methods for executing tests.
12 * 13 *
13 * This module includes: 14 * This module includes:
14 * - Managing parallel execution of tests, including timeout checks. 15 * - Managing parallel execution of tests, including timeout checks.
15 * - Evaluating the output of each test as pass/fail/crash/timeout. 16 * - Evaluating the output of each test as pass/fail/crash/timeout.
16 */ 17 */
17 18
18 final int NO_TIMEOUT = 0; 19 final int NO_TIMEOUT = 0;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 155 }
155 156
156 void timeoutHandler(Timer unusedTimer) { 157 void timeoutHandler(Timer unusedTimer) {
157 timedOut = true; 158 timedOut = true;
158 process.kill(); 159 process.kill();
159 } 160 }
160 } 161 }
161 162
162 163
163 class ProcessQueue { 164 class ProcessQueue {
164 int numProcesses = 0; 165 int _numProcesses = 0;
165 final int maxProcesses; 166 int _activeTestListers = 0;
166 Queue<TestCase> tests; 167 final int _maxProcesses;
167 ProgressIndicator progress; 168 Queue<TestCase> _tests;
168 var onDone; 169 ProgressIndicator _progress;
169 170
170 ProcessQueue(int this.maxProcesses, 171 ProcessQueue(int this._maxProcesses,
171 String progress, 172 String progress,
172 Date start_time, 173 Date start_time)
173 this.onDone) 174 : _tests = new Queue<TestCase>(),
174 : tests = new Queue<TestCase>(), 175 _progress = new ProgressIndicator.fromName(progress, start_time);
175 progress = new ProgressIndicator.fromName(progress, start_time);
176 176
177 tryRunTest() { 177 addTestSuite(TestSuite testSuite) {
178 if (tests.isEmpty() && numProcesses == 0) { 178 _activeTestListers++;
179 progress.allDone(); 179 testSuite.forEachTest(_runTest, _testListerDone);
180 onDone(); 180 }
181
182 _testListerDone() {
183 _activeTestListers--;
184 _checkDone();
185 }
186
187 _checkDone() {
188 if (_activeTestListers == 0 && _tests.isEmpty() && _numProcesses == 0) {
189 _progress.allDone();
181 } 190 }
182 if (numProcesses < maxProcesses && !tests.isEmpty()) { 191 }
183 TestCase test = tests.removeFirst(); 192
184 progress.start(test); 193 _runTest(TestCase test) {
194 _progress.testAdded();
195 _tests.add(test);
196 _tryRunTest();
197 }
198
199 _tryRunTest() {
200 _checkDone();
201 if (_numProcesses < _maxProcesses && !_tests.isEmpty()) {
202 TestCase test = _tests.removeFirst();
203 _progress.start(test);
185 Function oldCallback = test.completedHandler; 204 Function oldCallback = test.completedHandler;
186 Function wrapper = (TestCase test_arg) { 205 Function wrapper = (TestCase test_arg) {
187 numProcesses--; 206 _numProcesses--;
188 progress.done(test_arg); 207 _progress.done(test_arg);
189 tryRunTest(); 208 _tryRunTest();
190 oldCallback(test_arg); 209 oldCallback(test_arg);
191 }; 210 };
192 test.completedHandler = wrapper; 211 test.completedHandler = wrapper;
193 new RunningProcess(test, test.timeout).start(); 212 new RunningProcess(test, test.timeout).start();
194 numProcesses++; 213 _numProcesses++;
195 } 214 }
196 } 215 }
197
198 runTest(TestCase test) {
199 progress.testAdded();
200 tests.add(test);
201 tryRunTest();
202 }
203 } 216 }
OLDNEW
« no previous file with comments | « tools/testing/dart/test_progress.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698