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

Side by Side 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, 4 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library test.runner.runner_suite;
6
7 import 'dart:async';
8
9 import '../backend/metadata.dart';
10 import '../backend/operating_system.dart';
11 import '../backend/suite.dart';
12 import '../backend/test.dart';
13 import '../backend/test_platform.dart';
14 import '../util/async_thunk.dart';
15 import '../utils.dart';
16
17 /// A suite produced and consumed by the test runner that has runner-specific
18 /// logic and lifecycle management.
19 ///
20 /// This is separated from [Suite] because the backend library (which will
21 /// eventually become its own package) is primarily for test code itself to use,
22 /// for which the [RunnerSuite] APIs don't make sense.
23 class RunnerSuite extends Suite {
24 /// The thunk for running [close] exactly once.
25 final _closeThunk = new AsyncThunk();
26
27 /// The function to call when the suite is closed.
28 final AsyncFunction _onClose;
29
30 RunnerSuite(Iterable<Test> tests, {String path, TestPlatform platform,
31 OperatingSystem os, Metadata metadata, AsyncFunction onClose})
32 : super(tests,
33 path: path, platform: platform, os: os, metadata: metadata),
34 _onClose = onClose;
35
36 /// Creates a new [RunnerSuite] with the same properties as [suite].
37 RunnerSuite.fromSuite(Suite suite)
38 : super(suite.tests,
39 path: suite.path,
40 platform: suite.platform,
41 os: suite.os,
42 metadata: suite.metadata),
43 _onClose = null;
44
45 RunnerSuite change({String path, Metadata metadata, Iterable<Test> tests}) {
46 if (path == null) path = this.path;
47 if (metadata == null) metadata = this.metadata;
48 if (tests == null) tests = this.tests;
49 return new RunnerSuite(tests, platform: platform, os: os, path: path,
50 metadata: metadata, onClose: this.close);
51 }
52
53 /// Closes the suite and releases any resources associated with it.
54 Future close() {
55 return _closeThunk.run(() async {
56 if (_onClose != null) await _onClose();
57 });
58 }
59 }
OLDNEW
« 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