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

Unified Diff: test/runner/engine_test.dart

Issue 1580243002: Wait for a timed-out test's tear-down logic. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 4 years, 11 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 | « lib/src/frontend/timeout.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/runner/engine_test.dart
diff --git a/test/runner/engine_test.dart b/test/runner/engine_test.dart
index b3e7ad13a69151f20d4136af8cd7ee9046b3ee32..37a8120effd55bfc74aad5a8082aa4ffabb7ca0c 100644
--- a/test/runner/engine_test.dart
+++ b/test/runner/engine_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'dart:async';
+
import 'package:test/src/backend/group.dart';
import 'package:test/src/backend/state.dart';
import 'package:test/src/runner/engine.dart';
@@ -113,6 +115,42 @@ void main() {
expect(engine.run, throwsStateError);
});
+ test("runs tearDown after a test times out", () {
+ // Declare this here so the expect is in the context of this test, rather
+ // than the inner test.
+ var secondTestStarted = false;
+ var firstTestFinished = false;
+ var tearDownBody = expectAsync(() {
+ print("running teardown");
+ expect(secondTestStarted, isFalse);
+ expect(firstTestFinished, isFalse);
+ });
+
+ var engine = declareEngine(() {
+ // This ensures that the first test doesn't actually finish until the
+ // second test runs.
+ var firstTestCompleter = new Completer();
+
+ group("group", () {
+ tearDown(tearDownBody);
+
+ test("first test", () async {
+ print("running first test");
+ await firstTestCompleter.future;
+ firstTestFinished = true;
+ }, timeout: new Timeout(Duration.ZERO));
+ });
+
+ test("second test", () {
+ print("running second test");
+ secondTestStarted = true;
+ firstTestCompleter.complete();
+ });
+ });
+
+ expect(engine.run(), completes);
+ });
+
group("for a skipped test", () {
test("doesn't run the test's body", () async {
var bodyRun = false;
« no previous file with comments | « lib/src/frontend/timeout.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698