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

Unified Diff: lib/src/backend/suite.dart

Issue 1206033004: Only load a certain number of test suites at once. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 5 years, 6 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
Index: lib/src/backend/suite.dart
diff --git a/lib/src/backend/suite.dart b/lib/src/backend/suite.dart
index ec70b13d0f4869240931e6edd461e0209f6c4f93..50c408d0a99cb62cd916bf4ad3605e25c778ea41 100644
--- a/lib/src/backend/suite.dart
+++ b/lib/src/backend/suite.dart
@@ -4,8 +4,11 @@
library test.backend.suite;
+import 'dart:async';
import 'dart:collection';
+import '../util/async_thunk.dart';
+import '../utils.dart';
import 'metadata.dart';
import 'operating_system.dart';
import 'test.dart';
@@ -26,11 +29,19 @@ class Suite {
/// The metadata associated with this test suite.
final Metadata metadata;
+ /// The thunk for running [close] exactly once.
+ final _closeThunk = new AsyncThunk();
+
+ /// The function to call when the suite is closed.
+ final AsyncFunction _onClose;
+
/// The tests in the test suite.
final List<Test> tests;
- Suite(Iterable<Test> tests, {this.path, this.platform, Metadata metadata})
+ Suite(Iterable<Test> tests, {this.path, this.platform, Metadata metadata,
+ AsyncFunction onClose})
: metadata = metadata == null ? new Metadata() : metadata,
+ _onClose = onClose,
tests = new UnmodifiableListView<Test>(tests.toList());
/// Returns a view of this suite for the given [platform] and [os].
@@ -54,6 +65,14 @@ class Suite {
if (platform == null) platform = this.platform;
if (metadata == null) metadata = this.metadata;
if (tests == null) tests = this.tests;
- return new Suite(tests, path: path, platform: platform, metadata: metadata);
+ return new Suite(tests, path: path, platform: platform, 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 | « CHANGELOG.md ('k') | lib/src/executable.dart » ('j') | test/runner/signal_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698