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 import 'dart:async'; | 5 import 'dart:async'; |
6 | 6 |
7 import 'package:stack_trace/stack_trace.dart'; | 7 import 'package:stack_trace/stack_trace.dart'; |
8 | 8 |
9 import '../../test.dart'; | 9 import '../../test.dart'; |
10 import '../backend/group.dart'; | 10 import '../backend/group.dart'; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 Test get test => this.group.entries.single as Test; | 59 Test get test => this.group.entries.single as Test; |
60 | 60 |
61 /// Creates a load suite named [name] on [platform]. | 61 /// Creates a load suite named [name] on [platform]. |
62 /// | 62 /// |
63 /// [body] may return either a [RunnerSuite] or a [Future] that completes to a | 63 /// [body] may return either a [RunnerSuite] or a [Future] that completes to a |
64 /// [RunnerSuite]. Its return value is forwarded through [suite], although if | 64 /// [RunnerSuite]. Its return value is forwarded through [suite], although if |
65 /// it throws an error that will be forwarded through the suite's test. | 65 /// it throws an error that will be forwarded through the suite's test. |
66 /// | 66 /// |
67 /// If the the load test is closed before [body] is complete, it will close | 67 /// If the the load test is closed before [body] is complete, it will close |
68 /// the suite returned by [body] once it completes. | 68 /// the suite returned by [body] once it completes. |
69 factory LoadSuite(String name, SuiteConfiguration config, body(), | 69 factory LoadSuite( |
| 70 String name, SuiteConfiguration config, FutureOr<RunnerSuite> body(), |
70 {String path, TestPlatform platform}) { | 71 {String path, TestPlatform platform}) { |
71 var completer = new Completer<Pair<RunnerSuite, Zone>>.sync(); | 72 var completer = new Completer<Pair<RunnerSuite, Zone>>.sync(); |
72 return new LoadSuite._(name, config, () { | 73 return new LoadSuite._(name, config, () { |
73 var invoker = Invoker.current; | 74 var invoker = Invoker.current; |
74 invoker.addOutstandingCallback(); | 75 invoker.addOutstandingCallback(); |
75 | 76 |
76 invoke(() async { | 77 invoke(() async { |
77 try { | 78 try { |
78 var suite = await body(); | 79 var suite = await body(); |
79 if (completer.isCompleted) { | 80 if (completer.isCompleted) { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 } | 177 } |
177 | 178 |
178 LoadSuite filter(bool callback(Test test)) { | 179 LoadSuite filter(bool callback(Test test)) { |
179 var filtered = this.group.filter(callback); | 180 var filtered = this.group.filter(callback); |
180 if (filtered == null) filtered = new Group.root([], metadata: metadata); | 181 if (filtered == null) filtered = new Group.root([], metadata: metadata); |
181 return new LoadSuite._filtered(this, filtered); | 182 return new LoadSuite._filtered(this, filtered); |
182 } | 183 } |
183 | 184 |
184 Future close() async {} | 185 Future close() async {} |
185 } | 186 } |
OLD | NEW |