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

Unified 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, 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 | « test/runner/runner_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/runner/timeout_test.dart
diff --git a/test/runner/timeout_test.dart b/test/runner/timeout_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..e1c8a5f5fcb3a1879eb886f5b6667181202f2413
--- /dev/null
+++ b/test/runner/timeout_test.dart
@@ -0,0 +1,91 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// 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.
+
+@TestOn("vm")
+
+import 'dart:io';
+import 'dart:math' as math;
+
+import 'package:scheduled_test/descriptor.dart' as d;
+import 'package:scheduled_test/scheduled_stream.dart';
+import 'package:scheduled_test/scheduled_test.dart';
+import 'package:test/src/util/exit_codes.dart' as exit_codes;
+
+import '../io.dart';
+
+void main() {
+ useSandbox();
+
+ test("respects top-level @Timeout declarations", () {
+ d.file("test.dart", '''
+@Timeout(const Duration(seconds: 0))
+
+import 'dart:async';
+
+import 'package:test/test.dart';
+
+void main() {
+ test("timeout", () async {
+ await new Future.delayed(Duration.ZERO);
+ });
+}
+''').create();
+
+ var test = runTest(["test.dart"]);
+ test.stdout.expect(containsInOrder([
+ "Test timed out after 0 seconds.",
+ "-1: Some tests failed."
+ ]));
+ test.shouldExit(1);
+ });
+
+ test("respects the --timeout flag", () {
+ d.file("test.dart", '''
+import 'dart:async';
+
+import 'package:test/test.dart';
+
+void main() {
+ test("timeout", () async {
+ await new Future.delayed(Duration.ZERO);
+ });
+}
+''').create();
+
+ var test = runTest(["--timeout=0s", "test.dart"]);
+ test.stdout.expect(containsInOrder([
+ "Test timed out after 0 seconds.",
+ "-1: Some tests failed."
+ ]));
+ test.shouldExit(1);
+ });
+
+ test("the --timeout flag applies on top of the default 30s timeout", () {
+ d.file("test.dart", '''
+import 'dart:async';
+
+import 'package:test/test.dart';
+
+void main() {
+ test("no timeout", () async {
+ await new Future.delayed(new Duration(milliseconds: 250));
+ });
+
+ test("timeout", () async {
+ await new Future.delayed(new Duration(milliseconds: 750));
+ });
+}
+''').create();
+
+ // This should make the timeout about 500ms, which should cause exactly one
+ // test to fail.
+ var test = runTest(["--timeout=0.016x", "test.dart"]);
+ test.stdout.expect(containsInOrder([
+ "Test timed out after 0.4 seconds.",
+ "-1: Some tests failed."
+ ]));
+ test.shouldExit(1);
+ });
+}
+
« 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