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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2015, 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:async';
8 import 'dart:io';
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
14 import '../io.dart';
15
16 void main() {
17 useSandbox();
18
19 test("pauses the test runner for each file until the user presses enter", () {
20 d.file("test1.dart", """
21 import 'package:test/test.dart';
22
23 void main() {
24 print('loaded test 1!');
25
26 test("success", () {});
27 }
28 """).create();
29
30 d.file("test2.dart", """
31 import 'package:test/test.dart';
32
33 void main() {
34 print('loaded test 2!');
35
36 test("success", () {});
37 }
38 """).create();
39
40 var test = runTest(
41 ["--pause-after-load", "-p", "dartium", "test1.dart", "test2.dart"]);
42 test.stdout.expect(consumeThrough("loaded test 1!"));
43 test.stdout.expect(consumeThrough(inOrder([
44 "The test runner is paused. Open the dev console in Dartium and set "
45 "breakpoints. Once you're",
46 "finished, return to this terminal and press Enter."
47 ])));
48
49 schedule(() async {
50 var nextLineFired = false;
51 test.stdout.next().then(expectAsync((line) {
52 expect(line, contains("+0: test1.dart: success"));
53 nextLineFired = true;
54 }));
55
56 // Wait a little bit to be sure that the tests don't start running without
57 // our input.
58 await new Future.delayed(new Duration(seconds: 2));
59 expect(nextLineFired, isFalse);
60 });
61
62 test.writeLine('');
63
64 test.stdout.expect(consumeThrough("loaded test 2!"));
65 test.stdout.expect(consumeThrough(inOrder([
66 "The test runner is paused. Open the dev console in Dartium and set "
67 "breakpoints. Once you're",
68 "finished, return to this terminal and press Enter."
69 ])));
70
71 schedule(() async {
72 var nextLineFired = false;
73 test.stdout.next().then(expectAsync((line) {
74 expect(line, contains("+1: test2.dart: success"));
75 nextLineFired = true;
76 }));
77
78 // Wait a little bit to be sure that the tests don't start running without
79 // our input.
80 await new Future.delayed(new Duration(seconds: 2));
81 expect(nextLineFired, isFalse);
82 });
83
84 test.writeLine('');
85 test.stdout.expect(consumeThrough(contains("+2: All tests passed!")));
86 test.shouldExit(0);
87 });
88
89 test("pauses the test runner for each platform until the user presses enter",
90 () {
91 d.file("test.dart", """
92 import 'package:test/test.dart';
93
94 void main() {
95 print('loaded test!');
96
97 test("success", () {});
98 }
99 """).create();
100
101 var test = runTest(
102 ["--pause-after-load", "-p", "dartium", "-p", "chrome", "test.dart"]);
103 test.stdout.expect(consumeThrough("loaded test!"));
104 test.stdout.expect(consumeThrough(inOrder([
105 "The test runner is paused. Open the dev console in Dartium and set "
106 "breakpoints. Once you're",
107 "finished, return to this terminal and press Enter."
108 ])));
109
110 schedule(() async {
111 var nextLineFired = false;
112 test.stdout.next().then(expectAsync((line) {
113 expect(line, contains("+0: [Dartium] success"));
114 nextLineFired = true;
115 }));
116
117 // Wait a little bit to be sure that the tests don't start running without
118 // our input.
119 await new Future.delayed(new Duration(seconds: 2));
120 expect(nextLineFired, isFalse);
121 });
122
123 test.writeLine('');
124
125 test.stdout.expect(consumeThrough("loaded test!"));
126 test.stdout.expect(consumeThrough(inOrder([
127 "The test runner is paused. Open the dev console in Chrome and set "
128 "breakpoints. Once you're finished,",
129 "return to this terminal and press Enter."
130 ])));
131
132 schedule(() async {
133 var nextLineFired = false;
134 test.stdout.next().then(expectAsync((line) {
135 expect(line, contains("+1: [Chrome] success"));
136 nextLineFired = true;
137 }));
138
139 // Wait a little bit to be sure that the tests don't start running without
140 // our input.
141 await new Future.delayed(new Duration(seconds: 2));
142 expect(nextLineFired, isFalse);
143 });
144
145 test.writeLine('');
146 test.stdout.expect(consumeThrough(contains("+2: All tests passed!")));
147 test.shouldExit(0);
148 });
149
150 test("prints a warning and doesn't pause for unsupported platforms", () {
151 d.file("test.dart", """
152 import 'package:test/test.dart';
153
154 void main() {
155 test("success", () {});
156 }
157 """).create();
158
159 var test = runTest(
160 ["--pause-after-load", "-p", "vm", "-p", "content-shell", "test.dart"]);
161 test.stderr.expect(
162 "Warning: Debugging is currently unsupported on the Dart VM and "
163 "Dartium Content Shell.");
164 test.stdout.expect(consumeThrough(contains("+2: All tests passed!")));
165 test.shouldExit(0);
166 });
167
168 test("can mix supported and unsupported platforms", () {
169 d.file("test.dart", """
170 import 'package:test/test.dart';
171
172 void main() {
173 print('loaded test!');
174
175 test("success", () {});
176 }
177 """).create();
178
179 var test = runTest(
180 ["--pause-after-load", "-p", "dartium", "-p", "vm", "test.dart"]);
181 test.stderr.expect(
182 "Warning: Debugging is currently unsupported on the Dart VM.");
183
184 test.stdout.expect(consumeThrough("loaded test!"));
185 test.stdout.expect(consumeThrough(inOrder([
186 "The test runner is paused. Open the dev console in Dartium and set "
187 "breakpoints. Once you're",
188 "finished, return to this terminal and press Enter."
189 ])));
190
191 schedule(() async {
192 var nextLineFired = false;
193 test.stdout.next().then(expectAsync((line) {
194 expect(line, contains("+0: [Dartium] success"));
195 nextLineFired = true;
196 }));
197
198 // Wait a little bit to be sure that the tests don't start running without
199 // our input.
200 await new Future.delayed(new Duration(seconds: 2));
201 expect(nextLineFired, isFalse);
202 });
203
204 test.writeLine('');
205
206 test.stdout.expect(containsInOrder([
207 "loaded test!",
208 "+1: [VM] success",
209 "+2: All tests passed!"
210 ]));
211 test.shouldExit(0);
212 });
213
214 test("stops immediately if killed while paused", () {
215 d.file("test.dart", """
216 import 'package:test/test.dart';
217
218 void main() {
219 print('loaded test!');
220
221 test("success", () {});
222 }
223 """).create();
224
225 var test = runTest(["--pause-after-load", "-p", "dartium", "test.dart"]);
226 test.stdout.expect(consumeThrough("loaded test!"));
227 test.stdout.expect(consumeThrough(inOrder([
228 "The test runner is paused. Open the dev console in Dartium and set "
229 "breakpoints. Once you're",
230 "finished, return to this terminal and press Enter."
231 ])));
232
233 test.signal(ProcessSignal.SIGTERM);
234 test.shouldExit();
235 test.stderr.expect(isDone);
236 }, testOn: "!windows");
237 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698