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

Unified Diff: test/backend/invoker_test.dart

Issue 1090513002: Support configuring timeouts per-test and -group. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 5 years, 8 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 | « test/backend/declarer_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/backend/invoker_test.dart
diff --git a/test/backend/invoker_test.dart b/test/backend/invoker_test.dart
index 59d9c509d128b95480b399112afa8fc72ad3e0de..be27391e8fad341e5fdd39fb0c5a0a0dad74e93c 100644
--- a/test/backend/invoker_test.dart
+++ b/test/backend/invoker_test.dart
@@ -473,27 +473,6 @@ void main() {
});
});
- test("a test times out after 30 seconds", () {
- new FakeAsync().run((async) {
- var liveTest = _localTest(() {
- Invoker.current.addOutstandingCallback();
- }).load(suite);
-
- expectStates(liveTest, [
- const State(Status.running, Result.success),
- const State(Status.complete, Result.error)
- ]);
-
- expectErrors(liveTest, [(error) {
- expect(lastState.status, equals(Status.complete));
- expect(error, new isInstanceOf<TimeoutException>());
- }]);
-
- liveTest.run();
- async.elapse(new Duration(seconds: 30));
- });
- });
-
test("a test's prints are captured and reported", () {
expect(() {
var liveTest = _localTest(() {
@@ -507,7 +486,76 @@ void main() {
return liveTest.run();
}, prints(isEmpty));
});
+
+ group("timeout:", () {
+ test("a test times out after 30 seconds by default", () {
+ new FakeAsync().run((async) {
+ var liveTest = _localTest(() {
+ Invoker.current.addOutstandingCallback();
+ }).load(suite);
+
+ expectStates(liveTest, [
+ const State(Status.running, Result.success),
+ const State(Status.complete, Result.error)
+ ]);
+
+ expectErrors(liveTest, [(error) {
+ expect(lastState.status, equals(Status.complete));
+ expect(error, new isInstanceOf<TimeoutException>());
+ }]);
+
+ liveTest.run();
+ async.elapse(new Duration(seconds: 30));
+ });
+ });
+
+ test("a test's custom timeout takes precedence", () {
+ new FakeAsync().run((async) {
+ var liveTest = _localTest(() {
+ Invoker.current.addOutstandingCallback();
+ }, metadata: new Metadata(
+ timeout: new Timeout(new Duration(seconds: 15)))).load(suite);
+
+ expectStates(liveTest, [
+ const State(Status.running, Result.success),
+ const State(Status.complete, Result.error)
+ ]);
+
+ expectErrors(liveTest, [(error) {
+ expect(lastState.status, equals(Status.complete));
+ expect(error, new isInstanceOf<TimeoutException>());
+ }]);
+
+ liveTest.run();
+ async.elapse(new Duration(seconds: 15));
+ });
+ });
+
+ test("a timeout factor is applied on top of the 30s default", () {
+ new FakeAsync().run((async) {
+ var liveTest = _localTest(() {
+ Invoker.current.addOutstandingCallback();
+ }, metadata: new Metadata(timeout: new Timeout.factor(0.5)))
+ .load(suite);
+
+ expectStates(liveTest, [
+ const State(Status.running, Result.success),
+ const State(Status.complete, Result.error)
+ ]);
+
+ expectErrors(liveTest, [(error) {
+ expect(lastState.status, equals(Status.complete));
+ expect(error, new isInstanceOf<TimeoutException>());
+ }]);
+
+ liveTest.run();
+ async.elapse(new Duration(seconds: 15));
+ });
+ });
+ });
}
-LocalTest _localTest(body(), {tearDown()}) =>
- new LocalTest("test", new Metadata(), body, tearDown: tearDown);
+LocalTest _localTest(body(), {tearDown(), Metadata metadata}) {
+ if (metadata == null) metadata = new Metadata();
+ return new LocalTest("test", metadata, body, tearDown: tearDown);
+}
« no previous file with comments | « test/backend/declarer_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698