Index: mojo/public/dart/third_party/test/lib/src/runner/runner_suite.dart |
diff --git a/mojo/public/dart/third_party/test/lib/src/runner/runner_suite.dart b/mojo/public/dart/third_party/test/lib/src/runner/runner_suite.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2407f69fd267702c984fed1a95b159aa24fb7acc |
--- /dev/null |
+++ b/mojo/public/dart/third_party/test/lib/src/runner/runner_suite.dart |
@@ -0,0 +1,55 @@ |
+// 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 'package:async/async.dart'; |
+ |
+import '../backend/metadata.dart'; |
+import '../backend/operating_system.dart'; |
+import '../backend/suite.dart'; |
+import '../backend/test.dart'; |
+import '../backend/test_platform.dart'; |
+import '../utils.dart'; |
+import 'environment.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 { |
+ final Environment environment; |
+ |
+ /// The memoizer for running [close] exactly once. |
+ final _closeMemo = new AsyncMemoizer(); |
+ |
+ /// The function to call when the suite is closed. |
+ final AsyncFunction _onClose; |
+ |
+ RunnerSuite(this.environment, 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; |
+ |
+ 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(environment, tests, platform: platform, os: os, |
+ path: path, metadata: metadata, onClose: close); |
+ } |
+ |
+ /// Closes the suite and releases any resources associated with it. |
+ Future close() { |
+ return _closeMemo.runOnce(() async { |
+ if (_onClose != null) await _onClose(); |
+ }); |
+ } |
+} |