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

Side by Side Diff: test/runner/timeout_test.dart

Issue 1604043003: Add support for a timeout flag. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 4 years, 10 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 | « test/runner/runner_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
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.
4
5 @TestOn("vm")
6
7 import 'dart:io';
8 import 'dart:math' as math;
9
10 import 'package:scheduled_test/descriptor.dart' as d;
11 import 'package:scheduled_test/scheduled_stream.dart';
12 import 'package:scheduled_test/scheduled_test.dart';
13 import 'package:test/src/util/exit_codes.dart' as exit_codes;
14
15 import '../io.dart';
16
17 void main() {
18 useSandbox();
19
20 test("respects top-level @Timeout declarations", () {
21 d.file("test.dart", '''
22 @Timeout(const Duration(seconds: 0))
23
24 import 'dart:async';
25
26 import 'package:test/test.dart';
27
28 void main() {
29 test("timeout", () async {
30 await new Future.delayed(Duration.ZERO);
31 });
32 }
33 ''').create();
34
35 var test = runTest(["test.dart"]);
36 test.stdout.expect(containsInOrder([
37 "Test timed out after 0 seconds.",
38 "-1: Some tests failed."
39 ]));
40 test.shouldExit(1);
41 });
42
43 test("respects the --timeout flag", () {
44 d.file("test.dart", '''
45 import 'dart:async';
46
47 import 'package:test/test.dart';
48
49 void main() {
50 test("timeout", () async {
51 await new Future.delayed(Duration.ZERO);
52 });
53 }
54 ''').create();
55
56 var test = runTest(["--timeout=0s", "test.dart"]);
57 test.stdout.expect(containsInOrder([
58 "Test timed out after 0 seconds.",
59 "-1: Some tests failed."
60 ]));
61 test.shouldExit(1);
62 });
63
64 test("the --timeout flag applies on top of the default 30s timeout", () {
65 d.file("test.dart", '''
66 import 'dart:async';
67
68 import 'package:test/test.dart';
69
70 void main() {
71 test("no timeout", () async {
72 await new Future.delayed(new Duration(milliseconds: 250));
73 });
74
75 test("timeout", () async {
76 await new Future.delayed(new Duration(milliseconds: 750));
77 });
78 }
79 ''').create();
80
81 // This should make the timeout about 500ms, which should cause exactly one
82 // test to fail.
83 var test = runTest(["--timeout=0.016x", "test.dart"]);
84 test.stdout.expect(containsInOrder([
85 "Test timed out after 0.4 seconds.",
86 "-1: Some tests failed."
87 ]));
88 test.shouldExit(1);
89 });
90 }
91
OLDNEW
« no previous file with comments | « test/runner/runner_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698