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

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

Issue 1258163002: Split out a RunnerSuite class. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 5 years, 5 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/runner/loader.dart ('k') | lib/src/runner/vm/isolate_listener.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/runner/runner_suite.dart
diff --git a/lib/src/runner/runner_suite.dart b/lib/src/runner/runner_suite.dart
new file mode 100644
index 0000000000000000000000000000000000000000..589178ff7b3d3ebe6994ae76293e392b6b3a22b6
--- /dev/null
+++ b/lib/src/runner/runner_suite.dart
@@ -0,0 +1,59 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library test.runner.runner_suite;
+
+import 'dart:async';
+
+import '../backend/metadata.dart';
+import '../backend/operating_system.dart';
+import '../backend/suite.dart';
+import '../backend/test.dart';
+import '../backend/test_platform.dart';
+import '../util/async_thunk.dart';
+import '../utils.dart';
+
+/// A suite produced and consumed by the test runner that has runner-specific
+/// logic and lifecycle management.
+///
+/// This is separated from [Suite] because the backend library (which will
+/// eventually become its own package) is primarily for test code itself to use,
+/// for which the [RunnerSuite] APIs don't make sense.
+class RunnerSuite extends Suite {
+ /// The thunk for running [close] exactly once.
+ final _closeThunk = new AsyncThunk();
+
+ /// The function to call when the suite is closed.
+ final AsyncFunction _onClose;
+
+ RunnerSuite(Iterable<Test> tests, {String path, TestPlatform platform,
+ OperatingSystem os, Metadata metadata, AsyncFunction onClose})
+ : super(tests,
+ path: path, platform: platform, os: os, metadata: metadata),
+ _onClose = onClose;
+
+ /// Creates a new [RunnerSuite] with the same properties as [suite].
+ RunnerSuite.fromSuite(Suite suite)
+ : super(suite.tests,
+ path: suite.path,
+ platform: suite.platform,
+ os: suite.os,
+ metadata: suite.metadata),
+ _onClose = null;
+
+ RunnerSuite change({String path, Metadata metadata, Iterable<Test> tests}) {
+ if (path == null) path = this.path;
+ if (metadata == null) metadata = this.metadata;
+ if (tests == null) tests = this.tests;
+ return new RunnerSuite(tests, platform: platform, os: os, path: path,
+ metadata: metadata, onClose: this.close);
+ }
+
+ /// Closes the suite and releases any resources associated with it.
+ Future close() {
+ return _closeThunk.run(() async {
+ if (_onClose != null) await _onClose();
+ });
+ }
+}
« no previous file with comments | « lib/src/runner/loader.dart ('k') | lib/src/runner/vm/isolate_listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698