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 '../frontend/timeout.dart'; | 9 import '../frontend/timeout.dart'; |
10 import '../utils.dart'; | 10 import '../utils.dart'; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 /// Creates a group of tests. | 112 /// Creates a group of tests. |
113 void group(String name, void body(), {String testOn, Timeout timeout, skip, | 113 void group(String name, void body(), {String testOn, Timeout timeout, skip, |
114 Map<String, dynamic> onPlatform, tags}) { | 114 Map<String, dynamic> onPlatform, tags}) { |
115 _checkNotBuilt("group"); | 115 _checkNotBuilt("group"); |
116 | 116 |
117 var metadata = _metadata.merge(new Metadata.parse( | 117 var metadata = _metadata.merge(new Metadata.parse( |
118 testOn: testOn, timeout: timeout, skip: skip, onPlatform: onPlatform, | 118 testOn: testOn, timeout: timeout, skip: skip, onPlatform: onPlatform, |
119 tags: tags)); | 119 tags: tags)); |
120 var trace = new Trace.current(2); | 120 var trace = new Trace.current(2); |
121 | 121 |
122 // Don't load the tests for a skipped group. | |
123 if (metadata.skip) { | |
124 _entries.add(new Group(name, [], metadata: metadata, trace: trace)); | |
125 return; | |
126 } | |
127 | |
128 var declarer = new Declarer._(this, _prefix(name), metadata, trace); | 122 var declarer = new Declarer._(this, _prefix(name), metadata, trace); |
129 declarer.declare(body); | 123 declarer.declare(body); |
130 _entries.add(declarer.build()); | 124 _entries.add(declarer.build()); |
131 } | 125 } |
132 | 126 |
133 /// Returns [name] prefixed with this declarer's group name. | 127 /// Returns [name] prefixed with this declarer's group name. |
134 String _prefix(String name) => _name == null ? name : "$_name $name"; | 128 String _prefix(String name) => _name == null ? name : "$_name $name"; |
135 | 129 |
136 /// Registers a function to be run before each test in this group. | 130 /// Registers a function to be run before each test in this group. |
137 void setUp(callback()) { | 131 void setUp(callback()) { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 var completer = new Completer(); | 228 var completer = new Completer(); |
235 | 229 |
236 Invoker.current.addOutstandingCallback(); | 230 Invoker.current.addOutstandingCallback(); |
237 Invoker.current.waitForOutstandingCallbacks(() { | 231 Invoker.current.waitForOutstandingCallbacks(() { |
238 new Future.sync(body).whenComplete(completer.complete); | 232 new Future.sync(body).whenComplete(completer.complete); |
239 }).then((_) => Invoker.current.removeOutstandingCallback()); | 233 }).then((_) => Invoker.current.removeOutstandingCallback()); |
240 | 234 |
241 return completer.future; | 235 return completer.future; |
242 } | 236 } |
243 } | 237 } |
OLD | NEW |