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.backend.declarer; | 5 library test.backend.declarer; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import '../frontend/timeout.dart'; | 9 import '../frontend/timeout.dart'; |
10 import 'group.dart'; | 10 import 'group.dart'; |
(...skipping 27 matching lines...) Expand all Loading... | |
38 testOn: testOn, timeout: timeout, skip: skip, onPlatform: onPlatform)); | 38 testOn: testOn, timeout: timeout, skip: skip, onPlatform: onPlatform)); |
39 | 39 |
40 var group = _group; | 40 var group = _group; |
41 _tests.add(new LocalTest(description, metadata, () { | 41 _tests.add(new LocalTest(description, metadata, () { |
42 // TODO(nweiz): It might be useful to throw an error here if a test starts | 42 // TODO(nweiz): It might be useful to throw an error here if a test starts |
43 // running while other tests from the same declarer are also running, | 43 // running while other tests from the same declarer are also running, |
44 // since they might share closurized state. | 44 // since they might share closurized state. |
45 | 45 |
46 // TODO(nweiz): Use async/await here once issue 23497 has been fixed in | 46 // TODO(nweiz): Use async/await here once issue 23497 has been fixed in |
47 // two stable versions. | 47 // two stable versions. |
48 return group.runSetUp().then((_) => body()); | 48 return Invoker.current.waitForOutstandingCallbacks(() { |
49 }, tearDown: group.runTearDown)); | 49 return group.runSetUp().then((_) => body()); |
50 }).then((_) => group.runTearDown()); | |
Bob Nystrom
2015/09/24 16:05:02
Should this be whenComplete() or are errors alread
nweiz
2015/09/24 19:56:20
waitForOutstandingCallbacks has a zone error handl
| |
51 })); | |
50 } | 52 } |
51 | 53 |
52 /// Creates a group of tests. | 54 /// Creates a group of tests. |
53 void group(String description, void body(), {String testOn, | 55 void group(String description, void body(), {String testOn, |
54 Timeout timeout, skip, Map<String, dynamic> onPlatform}) { | 56 Timeout timeout, skip, Map<String, dynamic> onPlatform}) { |
55 var oldGroup = _group; | 57 var oldGroup = _group; |
56 | 58 |
57 var metadata = new Metadata.parse( | 59 var metadata = new Metadata.parse( |
58 testOn: testOn, timeout: timeout, skip: skip, onPlatform: onPlatform); | 60 testOn: testOn, timeout: timeout, skip: skip, onPlatform: onPlatform); |
59 | 61 |
(...skipping 24 matching lines...) Expand all Loading... | |
84 /// Registers a function to be run after tests. | 86 /// Registers a function to be run after tests. |
85 void tearDown(callback()) { | 87 void tearDown(callback()) { |
86 if (_group.tearDown != null) { | 88 if (_group.tearDown != null) { |
87 throw new StateError("tearDown() may not be called multiple times for " | 89 throw new StateError("tearDown() may not be called multiple times for " |
88 "the same group."); | 90 "the same group."); |
89 } | 91 } |
90 | 92 |
91 _group.tearDown = callback; | 93 _group.tearDown = callback; |
92 } | 94 } |
93 } | 95 } |
OLD | NEW |