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

Unified Diff: test/runner/pause_after_load_test.dart

Issue 1248073003: Add a --pause-after-load flag for debugging. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 5 years, 5 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
Index: test/runner/pause_after_load_test.dart
diff --git a/test/runner/pause_after_load_test.dart b/test/runner/pause_after_load_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..8b6eb2fba6d66ee877bc8d76b94a9e37ed152c50
--- /dev/null
+++ b/test/runner/pause_after_load_test.dart
@@ -0,0 +1,237 @@
+// Copyright (c) 2015, 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:async';
+import 'dart:io';
+
+import 'package:scheduled_test/descriptor.dart' as d;
+import 'package:scheduled_test/scheduled_stream.dart';
+import 'package:scheduled_test/scheduled_test.dart';
+
+import '../io.dart';
+
+void main() {
+ useSandbox();
+
+ test("pauses the test runner for each file until the user presses enter", () {
+ d.file("test1.dart", """
+import 'package:test/test.dart';
+
+void main() {
+ print('loaded test 1!');
+
+ test("success", () {});
+}
+""").create();
+
+ d.file("test2.dart", """
+import 'package:test/test.dart';
+
+void main() {
+ print('loaded test 2!');
+
+ test("success", () {});
+}
+""").create();
+
+ var test = runTest(
+ ["--pause-after-load", "-p", "dartium", "test1.dart", "test2.dart"]);
+ test.stdout.expect(consumeThrough("loaded test 1!"));
+ test.stdout.expect(consumeThrough(inOrder([
+ "The test runner is paused. Open the dev console in Dartium and set "
+ "breakpoints. Once you're",
+ "finished, return to this terminal and press Enter."
+ ])));
+
+ schedule(() async {
+ var nextLineFired = false;
+ test.stdout.next().then(expectAsync((line) {
+ expect(line, contains("+0: test1.dart: success"));
+ nextLineFired = true;
+ }));
+
+ // Wait a little bit to be sure that the tests don't start running without
+ // our input.
+ await new Future.delayed(new Duration(seconds: 2));
+ expect(nextLineFired, isFalse);
+ });
+
+ test.writeLine('');
+
+ test.stdout.expect(consumeThrough("loaded test 2!"));
+ test.stdout.expect(consumeThrough(inOrder([
+ "The test runner is paused. Open the dev console in Dartium and set "
+ "breakpoints. Once you're",
+ "finished, return to this terminal and press Enter."
+ ])));
+
+ schedule(() async {
+ var nextLineFired = false;
+ test.stdout.next().then(expectAsync((line) {
+ expect(line, contains("+1: test2.dart: success"));
+ nextLineFired = true;
+ }));
+
+ // Wait a little bit to be sure that the tests don't start running without
+ // our input.
+ await new Future.delayed(new Duration(seconds: 2));
+ expect(nextLineFired, isFalse);
+ });
+
+ test.writeLine('');
+ test.stdout.expect(consumeThrough(contains("+2: All tests passed!")));
+ test.shouldExit(0);
+ });
+
+ test("pauses the test runner for each platform until the user presses enter",
+ () {
+ d.file("test.dart", """
+import 'package:test/test.dart';
+
+void main() {
+ print('loaded test!');
+
+ test("success", () {});
+}
+""").create();
+
+ var test = runTest(
+ ["--pause-after-load", "-p", "dartium", "-p", "chrome", "test.dart"]);
+ test.stdout.expect(consumeThrough("loaded test!"));
+ test.stdout.expect(consumeThrough(inOrder([
+ "The test runner is paused. Open the dev console in Dartium and set "
+ "breakpoints. Once you're",
+ "finished, return to this terminal and press Enter."
+ ])));
+
+ schedule(() async {
+ var nextLineFired = false;
+ test.stdout.next().then(expectAsync((line) {
+ expect(line, contains("+0: [Dartium] success"));
+ nextLineFired = true;
+ }));
+
+ // Wait a little bit to be sure that the tests don't start running without
+ // our input.
+ await new Future.delayed(new Duration(seconds: 2));
+ expect(nextLineFired, isFalse);
+ });
+
+ test.writeLine('');
+
+ test.stdout.expect(consumeThrough("loaded test!"));
+ test.stdout.expect(consumeThrough(inOrder([
+ "The test runner is paused. Open the dev console in Chrome and set "
+ "breakpoints. Once you're finished,",
+ "return to this terminal and press Enter."
+ ])));
+
+ schedule(() async {
+ var nextLineFired = false;
+ test.stdout.next().then(expectAsync((line) {
+ expect(line, contains("+1: [Chrome] success"));
+ nextLineFired = true;
+ }));
+
+ // Wait a little bit to be sure that the tests don't start running without
+ // our input.
+ await new Future.delayed(new Duration(seconds: 2));
+ expect(nextLineFired, isFalse);
+ });
+
+ test.writeLine('');
+ test.stdout.expect(consumeThrough(contains("+2: All tests passed!")));
+ test.shouldExit(0);
+ });
+
+ test("prints a warning and doesn't pause for unsupported platforms", () {
+ d.file("test.dart", """
+import 'package:test/test.dart';
+
+void main() {
+ test("success", () {});
+}
+""").create();
+
+ var test = runTest(
+ ["--pause-after-load", "-p", "vm", "-p", "content-shell", "test.dart"]);
+ test.stderr.expect(
+ "Warning: Debugging is currently unsupported on the Dart VM and "
+ "Dartium Content Shell.");
+ test.stdout.expect(consumeThrough(contains("+2: All tests passed!")));
+ test.shouldExit(0);
+ });
+
+ test("can mix supported and unsupported platforms", () {
+ d.file("test.dart", """
+import 'package:test/test.dart';
+
+void main() {
+ print('loaded test!');
+
+ test("success", () {});
+}
+""").create();
+
+ var test = runTest(
+ ["--pause-after-load", "-p", "dartium", "-p", "vm", "test.dart"]);
+ test.stderr.expect(
+ "Warning: Debugging is currently unsupported on the Dart VM.");
+
+ test.stdout.expect(consumeThrough("loaded test!"));
+ test.stdout.expect(consumeThrough(inOrder([
+ "The test runner is paused. Open the dev console in Dartium and set "
+ "breakpoints. Once you're",
+ "finished, return to this terminal and press Enter."
+ ])));
+
+ schedule(() async {
+ var nextLineFired = false;
+ test.stdout.next().then(expectAsync((line) {
+ expect(line, contains("+0: [Dartium] success"));
+ nextLineFired = true;
+ }));
+
+ // Wait a little bit to be sure that the tests don't start running without
+ // our input.
+ await new Future.delayed(new Duration(seconds: 2));
+ expect(nextLineFired, isFalse);
+ });
+
+ test.writeLine('');
+
+ test.stdout.expect(containsInOrder([
+ "loaded test!",
+ "+1: [VM] success",
+ "+2: All tests passed!"
+ ]));
+ test.shouldExit(0);
+ });
+
+ test("stops immediately if killed while paused", () {
+ d.file("test.dart", """
+import 'package:test/test.dart';
+
+void main() {
+ print('loaded test!');
+
+ test("success", () {});
+}
+""").create();
+
+ var test = runTest(["--pause-after-load", "-p", "dartium", "test.dart"]);
+ test.stdout.expect(consumeThrough("loaded test!"));
+ test.stdout.expect(consumeThrough(inOrder([
+ "The test runner is paused. Open the dev console in Dartium and set "
+ "breakpoints. Once you're",
+ "finished, return to this terminal and press Enter."
+ ])));
+
+ test.signal(ProcessSignal.SIGTERM);
+ test.shouldExit();
+ test.stderr.expect(isDone);
+ }, testOn: "!windows");
+}

Powered by Google App Engine
This is Rietveld 408576698