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

Unified Diff: lib/src/runner/engine.dart

Issue 1093633004: Add test- and group-level support for skipping tests. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/backend/metadata.dart ('k') | lib/src/runner/loader.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/runner/engine.dart
diff --git a/lib/src/runner/engine.dart b/lib/src/runner/engine.dart
index 6aba4ed1e1155a2545fc5254c310fc2ec5b80023..3ddadd5731cc9a936528716b83971750d172f2bf 100644
--- a/lib/src/runner/engine.dart
+++ b/lib/src/runner/engine.dart
@@ -10,8 +10,10 @@ import 'dart:collection';
import 'package:pool/pool.dart';
import '../backend/live_test.dart';
+import '../backend/live_test_controller.dart';
import '../backend/state.dart';
import '../backend/suite.dart';
+import '../backend/test.dart';
import '../utils.dart';
/// An [Engine] manages a run that encompasses multiple test suites.
@@ -41,6 +43,10 @@ class Engine {
List<LiveTest> get liveTests =>
new UnmodifiableListView(flatten(_liveTestsBySuite));
+ /// The tests in [liveTests], organized by their original test suite.
+ ///
+ /// This allows test suites to be run in parallel without running multiple
+ /// tests in the same suite at once.
final List<List<LiveTest>> _liveTestsBySuite;
/// A stream that emits each [LiveTest] as it's about to start running.
@@ -49,10 +55,33 @@ class Engine {
Stream<LiveTest> get onTestStarted => _onTestStartedController.stream;
final _onTestStartedController = new StreamController<LiveTest>.broadcast();
+ /// Returns the tests in [suites] grouped by suite.
+ ///
+ /// Also replaces tests marked as "skip" with dummy [LiveTest]s.
+ static List<List<LiveTest>> _computeLiveTestsBySuite(Iterable<Suite> suites) {
+ return suites.map((suite) {
+ return suite.tests.map((test) {
+ return test.metadata.skip
+ ? _skippedTest(suite, test)
+ : test.load(suite);
+ }).toList();
+ }).toList();
+ }
+
+ /// Returns a dummy [LiveTest] for a test marked as "skip".
+ static LiveTest _skippedTest(Suite suite, Test test) {
+ var controller;
+ controller = new LiveTestController(suite, test, () {
+ controller.setState(const State(Status.running, Result.success));
+ controller.setState(const State(Status.complete, Result.success));
+ controller.completer.complete();
+ }, () {});
+ return controller.liveTest;
+ }
+
/// Creates an [Engine] that will run all tests in [suites].
Engine(Iterable<Suite> suites, {int concurrency})
- : _liveTestsBySuite = suites.map((suite) =>
- suite.tests.map((test) => test.load(suite)).toList()).toList(),
+ : _liveTestsBySuite = _computeLiveTestsBySuite(suites),
_pool = new Pool(concurrency == null ? 1 : concurrency);
/// Runs all tests in all suites defined by this engine.
« no previous file with comments | « lib/src/backend/metadata.dart ('k') | lib/src/runner/loader.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698