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

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

Issue 1465403002: Revert "Add RunnerSuite.{on,is}Debugging properties." (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/runner/load_suite.dart ('k') | no next file » | 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
index 018cccd0be1ec7d3b6b264f480d0a7ff3be96b71..fe6090c46487b6b69e20d314f91c0326e26ecf28 100644
--- a/lib/src/runner/runner_suite.dart
+++ b/lib/src/runner/runner_suite.dart
@@ -22,88 +22,31 @@ import 'environment.dart';
/// 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.
-///
-/// A [RunnerSuite] can be produced and controlled using a
-/// [RunnerSuiteController].
class RunnerSuite extends Suite {
- final RunnerSuiteController _controller;
-
- /// The environment in which this suite runs.
- Environment get environment => _controller._environment;
-
- /// Whether the suite is paused for debugging.
- ///
- /// When using a dev inspector, this may also mean that the entire browser is
- /// paused.
- bool get isDebugging => _controller._isDebugging;
+ final Environment environment;
- /// A broadcast stream that emits an event whenever the suite is paused for
- /// debugging or resumed afterwards.
- ///
- /// The event is `true` when debugging starts and `false` when it ends.
- Stream<bool> get onDebugging => _controller._onDebuggingController.stream;
+ /// The memoizer for running [close] exactly once.
+ final _closeMemo = new AsyncMemoizer();
- /// A shortcut constructor for creating a [RunnerSuite] that never goes into
- /// debugging mode.
- factory RunnerSuite(Environment environment, Group group, {String path,
- TestPlatform platform, OperatingSystem os, AsyncFunction onClose}) {
- var controller = new RunnerSuiteController(environment, group,
- path: path, platform: platform, os: os, onClose: onClose);
- return controller.suite;
- }
+ /// The function to call when the suite is closed.
+ final AsyncFunction _onClose;
- RunnerSuite._(this._controller, Group group, String path,
- TestPlatform platform, OperatingSystem os)
- : super(group, path: path, platform: platform, os: os);
+ RunnerSuite(this.environment, Group group, {String path,
+ TestPlatform platform, OperatingSystem os, AsyncFunction onClose})
+ : _onClose = onClose,
+ super(group, path: path, platform: platform, os: os);
RunnerSuite filter(bool callback(Test test)) {
var filtered = group.filter(callback);
filtered ??= new Group.root([], metadata: metadata);
- return new RunnerSuite._(_controller, filtered, path, platform, os);
+ return new RunnerSuite(environment, filtered,
+ platform: platform, os: os, path: path);
}
/// Closes the suite and releases any resources associated with it.
- Future close() => _controller._close();
-}
-
-/// A class that exposes and controls a [RunnerSuite].
-class RunnerSuiteController {
- /// The suite controlled by this controller.
- RunnerSuite get suite => _suite;
- RunnerSuite _suite;
-
- /// The backing value for [suite.environment].
- final Environment _environment;
-
- /// The function to call when the suite is closed.
- final AsyncFunction _onClose;
-
- /// The backing value for [suite.isDebugging].
- bool _isDebugging = false;
-
- /// The controller for [suite.onDebugging].
- final _onDebuggingController = new StreamController<bool>.broadcast();
-
- RunnerSuiteController(this._environment, Group group, {String path,
- TestPlatform platform, OperatingSystem os, AsyncFunction onClose})
- : _onClose = onClose {
- _suite = new RunnerSuite._(this, group, path, platform, os);
- }
-
- /// Sets whether the suite is paused for debugging.
- ///
- /// If this is different than [suite.isDebugging], this will automatically
- /// send out an event along [suite.onDebugging].
- void setDebugging(bool debugging) {
- if (debugging == _isDebugging) return;
- _isDebugging = debugging;
- _onDebuggingController.add(debugging);
+ Future close() {
+ return _closeMemo.runOnce(() async {
+ if (_onClose != null) await _onClose();
+ });
}
-
- /// The backing function for [suite.close].
- Future _close() => _closeMemo.runOnce(() async {
- _onDebuggingController.close();
- if (_onClose != null) await _onClose();
- });
- final _closeMemo = new AsyncMemoizer();
}
« no previous file with comments | « lib/src/runner/load_suite.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698