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

Side by Side Diff: lib/src/runner/runner_suite.dart

Issue 1379203002: Refactor groups to pipe them through to the runner. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 5 years, 2 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
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.runner.runner_suite; 5 library test.runner.runner_suite;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:async/async.dart'; 9 import 'package:async/async.dart';
10 10
11 import '../backend/metadata.dart'; 11 import '../backend/metadata.dart';
12 import '../backend/operating_system.dart'; 12 import '../backend/operating_system.dart';
13 import '../backend/suite.dart'; 13 import '../backend/suite.dart';
14 import '../backend/suite_entry.dart';
14 import '../backend/test.dart'; 15 import '../backend/test.dart';
15 import '../backend/test_platform.dart'; 16 import '../backend/test_platform.dart';
16 import '../utils.dart'; 17 import '../utils.dart';
17 import 'environment.dart'; 18 import 'environment.dart';
18 19
19 /// A suite produced and consumed by the test runner that has runner-specific 20 /// A suite produced and consumed by the test runner that has runner-specific
20 /// logic and lifecycle management. 21 /// logic and lifecycle management.
21 /// 22 ///
22 /// This is separated from [Suite] because the backend library (which will 23 /// This is separated from [Suite] because the backend library (which will
23 /// eventually become its own package) is primarily for test code itself to use, 24 /// eventually become its own package) is primarily for test code itself to use,
24 /// for which the [RunnerSuite] APIs don't make sense. 25 /// for which the [RunnerSuite] APIs don't make sense.
25 class RunnerSuite extends Suite { 26 class RunnerSuite extends Suite {
26 final Environment environment; 27 final Environment environment;
27 28
28 /// The memoizer for running [close] exactly once. 29 /// The memoizer for running [close] exactly once.
29 final _closeMemo = new AsyncMemoizer(); 30 final _closeMemo = new AsyncMemoizer();
30 31
31 /// The function to call when the suite is closed. 32 /// The function to call when the suite is closed.
32 final AsyncFunction _onClose; 33 final AsyncFunction _onClose;
33 34
34 RunnerSuite(this.environment, Iterable<Test> tests, {String path, 35 RunnerSuite(this.environment, Iterable<SuiteEntry> entries, {String path,
35 TestPlatform platform, OperatingSystem os, Metadata metadata, 36 TestPlatform platform, OperatingSystem os, Metadata metadata,
36 AsyncFunction onClose}) 37 AsyncFunction onClose})
37 : super(tests, 38 : super(entries,
38 path: path, platform: platform, os: os, metadata: metadata), 39 path: path, platform: platform, os: os, metadata: metadata),
39 _onClose = onClose; 40 _onClose = onClose;
40 41
41 RunnerSuite change({String path, Metadata metadata, Iterable<Test> tests}) { 42 RunnerSuite filter(bool callback(Test test)) {
42 if (path == null) path = this.path; 43 var filtered = entries
43 if (metadata == null) metadata = this.metadata; 44 .map((entry) => entry.filter(callback))
44 if (tests == null) tests = this.tests; 45 .where((entry) => entry != null)
45 return new RunnerSuite(environment, tests, platform: platform, os: os, 46 .toList();
46 path: path, metadata: metadata, onClose: close); 47 return new RunnerSuite(environment, filtered,
48 platform: platform, os: os, path: path, metadata: metadata);
47 } 49 }
48 50
49 /// Closes the suite and releases any resources associated with it. 51 /// Closes the suite and releases any resources associated with it.
50 Future close() { 52 Future close() {
51 return _closeMemo.runOnce(() async { 53 return _closeMemo.runOnce(() async {
52 if (_onClose != null) await _onClose(); 54 if (_onClose != null) await _onClose();
53 }); 55 });
54 } 56 }
55 } 57 }
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