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

Side by Side Diff: lib/src/backend/group.dart

Issue 1372353003: Don't early-exit teardowns after a signal. (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 | « CHANGELOG.md ('k') | lib/src/backend/invoker.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.backend.group; 5 library test.backend.group;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import '../utils.dart'; 9 import '../utils.dart';
10 import 'invoker.dart'; 10 import 'invoker.dart';
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 67 }
68 68
69 return Future.forEach(setUps, (setUp) => setUp()); 69 return Future.forEach(setUps, (setUp) => setUp());
70 } 70 }
71 71
72 /// Run the tear-up functions for this and any parent groups. 72 /// Run the tear-up functions for this and any parent groups.
73 /// 73 ///
74 /// If no set-up functions are declared, this returns a [Future] that 74 /// If no set-up functions are declared, this returns a [Future] that
75 /// completes immediately. 75 /// completes immediately.
76 Future runTearDowns() { 76 Future runTearDowns() {
77 // TODO(nweiz): Use async/await here once issue 23497 has been fixed in two 77 return Invoker.current.unclosable(() {
78 // stable versions. 78 var tearDowns = [];
79 if (parent == null) { 79 for (var group = this; group != null; group = group.parent) {
80 return Future.forEach(tearDowns.reversed, _errorsDontStopTest); 80 tearDowns.addAll(group.tearDowns.reversed);
81 } 81 }
82 82
83 return Future.forEach(tearDowns.reversed, _errorsDontStopTest) 83 return Future.forEach(tearDowns, _errorsDontStopTest);
84 .then((_) => parent.runTearDowns()); 84 });
85 } 85 }
86 86
87 /// Runs [body] with special error-handling behavior. 87 /// Runs [body] with special error-handling behavior.
88 /// 88 ///
89 /// Errors emitted [body] will still cause be the test to fail, but they won't 89 /// Errors emitted [body] will still cause be the test to fail, but they won't
90 /// cause it to *stop*. In particular, they won't remove any outstanding 90 /// cause it to *stop*. In particular, they won't remove any outstanding
91 /// callbacks registered outside of [body]. 91 /// callbacks registered outside of [body].
92 Future _errorsDontStopTest(body()) { 92 Future _errorsDontStopTest(body()) {
93 var completer = new Completer(); 93 var completer = new Completer();
94 94
95 Invoker.current.addOutstandingCallback(); 95 Invoker.current.addOutstandingCallback();
96 Invoker.current.waitForOutstandingCallbacks(() { 96 Invoker.current.waitForOutstandingCallbacks(() {
97 new Future.sync(body).whenComplete(completer.complete); 97 new Future.sync(body).whenComplete(completer.complete);
98 }).then((_) => Invoker.current.removeOutstandingCallback()); 98 }).then((_) => Invoker.current.removeOutstandingCallback());
99 99
100 return completer.future; 100 return completer.future;
101 } 101 }
102 } 102 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/backend/invoker.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698