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

Side by Side Diff: lib/src/runner/engine.dart

Issue 1390883002: Make Suite contain a single Group. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 5 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
« no previous file with comments | « lib/src/runner/browser/iframe_listener.dart ('k') | lib/src/runner/load_exception_suite.dart » ('j') | 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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.engine; 5 library test.runner.engine;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:async/async.dart' hide Result; 10 import 'package:async/async.dart' hide Result;
11 import 'package:collection/collection.dart'; 11 import 'package:collection/collection.dart';
12 import 'package:pool/pool.dart'; 12 import 'package:pool/pool.dart';
13 13
14 import '../backend/group.dart'; 14 import '../backend/group.dart';
15 import '../backend/invoker.dart'; 15 import '../backend/invoker.dart';
16 import '../backend/live_test.dart'; 16 import '../backend/live_test.dart';
17 import '../backend/live_test_controller.dart'; 17 import '../backend/live_test_controller.dart';
18 import '../backend/state.dart'; 18 import '../backend/state.dart';
19 import '../backend/suite_entry.dart'; 19 import '../backend/group_entry.dart';
20 import '../backend/test.dart'; 20 import '../backend/test.dart';
21 import 'load_suite.dart'; 21 import 'load_suite.dart';
22 import 'runner_suite.dart'; 22 import 'runner_suite.dart';
23 23
24 /// An [Engine] manages a run that encompasses multiple test suites. 24 /// An [Engine] manages a run that encompasses multiple test suites.
25 /// 25 ///
26 /// Test suites are provided by passing them into [suiteSink]. Once all suites 26 /// Test suites are provided by passing them into [suiteSink]. Once all suites
27 /// have been provided, the user should close [suiteSink] to indicate this. 27 /// have been provided, the user should close [suiteSink] to indicate this.
28 /// [run] won't terminate until [suiteSink] is closed. Suites will be run in the 28 /// [run] won't terminate until [suiteSink] is closed. Suites will be run in the
29 /// order they're provided to [suiteSink]. Tests within those suites will 29 /// order they're provided to [suiteSink]. Tests within those suites will
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 if (suite is LoadSuite) { 192 if (suite is LoadSuite) {
193 suite = await _addLoadSuite(suite); 193 suite = await _addLoadSuite(suite);
194 if (suite == null) { 194 if (suite == null) {
195 loadResource.release(); 195 loadResource.release();
196 return; 196 return;
197 } 197 }
198 } 198 }
199 199
200 await _runPool.withResource(() async { 200 await _runPool.withResource(() async {
201 if (_closed) return; 201 if (_closed) return;
202 await _runEntries(suite, suite.entries); 202 await _runGroup(suite, suite.group);
203 loadResource.allowRelease(() => suite.close()); 203 loadResource.allowRelease(() => suite.close());
204 }); 204 });
205 })); 205 }));
206 }, onDone: _group.close); 206 }, onDone: _group.close);
207 207
208 return success; 208 return success;
209 } 209 }
210 210
211 /// Runs all the entries in [entries] in sequence. 211 /// Runs all the entries in [entries] in sequence.
212 Future _runEntries(RunnerSuite suite, List<SuiteEntry> entries) async { 212 Future _runGroup(RunnerSuite suite, Group group) async {
213 for (var entry in entries) { 213 if (group.metadata.skip) {
214 await _runLiveTest(_skippedTest(suite, group));
215 return;
216 }
217
218 for (var entry in group.entries) {
214 if (_closed) return; 219 if (_closed) return;
215 220
216 if (entry.metadata.skip) { 221 if (entry is Group) {
222 await _runGroup(suite, entry);
223 } else if (entry.metadata.skip) {
217 await _runLiveTest(_skippedTest(suite, entry)); 224 await _runLiveTest(_skippedTest(suite, entry));
218 } else if (entry is Test) {
219 await _runLiveTest(entry.load(suite));
220 } else { 225 } else {
221 var group = entry as Group; 226 var test = entry as Test;
222 await _runEntries(suite, group.entries); 227 await _runLiveTest(test.load(suite));
223 } 228 }
224 } 229 }
225 } 230 }
226 231
227 /// Returns a dummy [LiveTest] for a test or group marked as "skip". 232 /// Returns a dummy [LiveTest] for a test or group marked as "skip".
228 LiveTest _skippedTest(RunnerSuite suite, SuiteEntry entry) { 233 LiveTest _skippedTest(RunnerSuite suite, GroupEntry entry) {
229 var test = new LocalTest(entry.name, entry.metadata, () {}); 234 // The netry name will be `null` for the root group.
235 var test = new LocalTest(entry.name ?? "(suite)", entry.metadata, () {});
236
230 var controller; 237 var controller;
231 controller = new LiveTestController(suite, test, () { 238 controller = new LiveTestController(suite, test, () {
232 controller.setState(const State(Status.running, Result.success)); 239 controller.setState(const State(Status.running, Result.success));
233 controller.setState(const State(Status.complete, Result.success)); 240 controller.setState(const State(Status.complete, Result.success));
234 controller.completer.complete(); 241 controller.completer.complete();
235 }, () {}); 242 }, () {});
236 return controller.liveTest; 243 return controller.liveTest;
237 } 244 }
238 245
239 /// Runs [liveTest]. 246 /// Runs [liveTest].
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 347
341 // Close the running tests first so that we're sure to wait for them to 348 // Close the running tests first so that we're sure to wait for them to
342 // finish before we close their suites and cause them to become unloaded. 349 // finish before we close their suites and cause them to become unloaded.
343 var allLiveTests = liveTests.toSet()..addAll(_activeLoadTests); 350 var allLiveTests = liveTests.toSet()..addAll(_activeLoadTests);
344 await Future.wait(allLiveTests.map((liveTest) => liveTest.close())); 351 await Future.wait(allLiveTests.map((liveTest) => liveTest.close()));
345 352
346 var allSuites = allLiveTests.map((liveTest) => liveTest.suite).toSet(); 353 var allSuites = allLiveTests.map((liveTest) => liveTest.suite).toSet();
347 await Future.wait(allSuites.map((suite) => suite.close())); 354 await Future.wait(allSuites.map((suite) => suite.close()));
348 } 355 }
349 } 356 }
OLDNEW
« no previous file with comments | « lib/src/runner/browser/iframe_listener.dart ('k') | lib/src/runner/load_exception_suite.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698