OLD | NEW |
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 |
(...skipping 15 matching lines...) Expand all Loading... |
26 final Environment environment; | 26 final Environment environment; |
27 | 27 |
28 /// The memoizer for running [close] exactly once. | 28 /// The memoizer for running [close] exactly once. |
29 final _closeMemo = new AsyncMemoizer(); | 29 final _closeMemo = new AsyncMemoizer(); |
30 | 30 |
31 /// The function to call when the suite is closed. | 31 /// The function to call when the suite is closed. |
32 final AsyncFunction _onClose; | 32 final AsyncFunction _onClose; |
33 | 33 |
34 RunnerSuite(this.environment, Group group, {String path, | 34 RunnerSuite(this.environment, Group group, {String path, |
35 TestPlatform platform, OperatingSystem os, AsyncFunction onClose}) | 35 TestPlatform platform, OperatingSystem os, AsyncFunction onClose}) |
36 : super(group, path: path, platform: platform, os: os), | 36 : _onClose = onClose, |
37 _onClose = onClose; | 37 super(group, path: path, platform: platform, os: os); |
38 | 38 |
39 RunnerSuite filter(bool callback(Test test)) { | 39 RunnerSuite filter(bool callback(Test test)) { |
40 var filtered = group.filter(callback); | 40 var filtered = group.filter(callback); |
41 filtered ??= new Group.root([], metadata: metadata); | 41 filtered ??= new Group.root([], metadata: metadata); |
42 return new RunnerSuite(environment, filtered, | 42 return new RunnerSuite(environment, filtered, |
43 platform: platform, os: os, path: path); | 43 platform: platform, os: os, path: path); |
44 } | 44 } |
45 | 45 |
46 /// Closes the suite and releases any resources associated with it. | 46 /// Closes the suite and releases any resources associated with it. |
47 Future close() { | 47 Future close() { |
48 return _closeMemo.runOnce(() async { | 48 return _closeMemo.runOnce(() async { |
49 if (_onClose != null) await _onClose(); | 49 if (_onClose != null) await _onClose(); |
50 }); | 50 }); |
51 } | 51 } |
52 } | 52 } |
OLD | NEW |