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

Unified Diff: lib/src/backend/group.dart

Issue 1364893004: Run outer tearDown()s even if inner ones fail. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: More robust Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/backend/group.dart
diff --git a/lib/src/backend/group.dart b/lib/src/backend/group.dart
index 69144c6b84ff1f8585909898ec8c467a4b47c71b..d1bc67a390a07ed39c45e04fc13001e6c7945b4a 100644
--- a/lib/src/backend/group.dart
+++ b/lib/src/backend/group.dart
@@ -7,6 +7,7 @@ library test.backend.group;
import 'dart:async';
import '../utils.dart';
+import 'invoker.dart';
import 'metadata.dart';
/// A group contains multiple tests and subgroups.
@@ -76,13 +77,25 @@ class Group {
Future runTearDown() {
// TODO(nweiz): Use async/await here once issue 23497 has been fixed in two
// stable versions.
- if (parent != null) {
- return new Future.sync(() {
- if (tearDown != null) return tearDown();
- }).then((_) => parent.runTearDown());
+ if (parent == null) {
+ return tearDown == null ? new Future.value() : new Future.sync(tearDown);
}
- if (tearDown != null) return new Future.sync(tearDown);
- return new Future.value();
+ return _errorsDontStopTest(() {
+ if (tearDown != null) return tearDown();
+ }).then((_) => parent.runTearDown());
+ }
+
+ /// Runs [body] with special error-handling behavior.
kevmoo 2015/09/24 21:07:30 Is the case this addresses already covered in the
nweiz 2015/09/24 21:13:07 Yeah; the test coincidentally passed because of th
+ ///
+ /// Errors emitted [body] will still cause be the test to fail, but they won't
+ /// cause it to *stop*. In particular, they won't remove any outstanding
+ /// callbacks registered outside of [body].
+ Future _errorsDontStopTest(body()) {
+ var completer = new Completer();
+ Invoker.current.waitForOutstandingCallbacks(() {
+ new Future.sync(body).whenComplete(completer.complete);
+ });
+ return completer.future;
}
}
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698