OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 @TestOn("vm") | 5 @TestOn("vm") |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 | 9 |
10 import 'package:scheduled_test/descriptor.dart' as d; | 10 import 'package:scheduled_test/descriptor.dart' as d; |
(...skipping 23 matching lines...) Expand all Loading... |
34 print('loaded test 2!'); | 34 print('loaded test 2!'); |
35 | 35 |
36 test("success", () {}); | 36 test("success", () {}); |
37 } | 37 } |
38 """).create(); | 38 """).create(); |
39 | 39 |
40 var test = runTest( | 40 var test = runTest( |
41 ["--pause-after-load", "-p", "dartium", "test1.dart", "test2.dart"]); | 41 ["--pause-after-load", "-p", "dartium", "test1.dart", "test2.dart"]); |
42 test.stdout.expect(consumeThrough("loaded test 1!")); | 42 test.stdout.expect(consumeThrough("loaded test 1!")); |
43 test.stdout.expect(consumeThrough(inOrder([ | 43 test.stdout.expect(consumeThrough(inOrder([ |
44 "The test runner is paused. Open the dev console in Dartium and set " | 44 startsWith("Observatory URL: "), |
45 "breakpoints. Once you're", | 45 "The test runner is paused. Open the dev console in Dartium or the " |
46 "finished, return to this terminal and press Enter." | 46 "Observatory and set breakpoints.", |
| 47 "Once you're finished, return to this terminal and press Enter." |
47 ]))); | 48 ]))); |
48 | 49 |
49 schedule(() async { | 50 schedule(() async { |
50 var nextLineFired = false; | 51 var nextLineFired = false; |
51 test.stdout.next().then(expectAsync((line) { | 52 test.stdout.next().then(expectAsync((line) { |
52 expect(line, contains("+0: test1.dart: success")); | 53 expect(line, contains("+0: test1.dart: success")); |
53 nextLineFired = true; | 54 nextLineFired = true; |
54 })); | 55 })); |
55 | 56 |
56 // Wait a little bit to be sure that the tests don't start running without | 57 // Wait a little bit to be sure that the tests don't start running without |
57 // our input. | 58 // our input. |
58 await new Future.delayed(new Duration(seconds: 2)); | 59 await new Future.delayed(new Duration(seconds: 2)); |
59 expect(nextLineFired, isFalse); | 60 expect(nextLineFired, isFalse); |
60 }); | 61 }); |
61 | 62 |
62 test.writeLine(''); | 63 test.writeLine(''); |
63 | 64 |
64 test.stdout.expect(consumeThrough("loaded test 2!")); | 65 test.stdout.expect(consumeThrough("loaded test 2!")); |
65 test.stdout.expect(consumeThrough(inOrder([ | 66 test.stdout.expect(consumeThrough(inOrder([ |
66 "The test runner is paused. Open the dev console in Dartium and set " | 67 startsWith("Observatory URL: "), |
67 "breakpoints. Once you're", | 68 "The test runner is paused. Open the dev console in Dartium or the " |
68 "finished, return to this terminal and press Enter." | 69 "Observatory and set breakpoints.", |
| 70 "Once you're finished, return to this terminal and press Enter." |
69 ]))); | 71 ]))); |
70 | 72 |
71 schedule(() async { | 73 schedule(() async { |
72 var nextLineFired = false; | 74 var nextLineFired = false; |
73 test.stdout.next().then(expectAsync((line) { | 75 test.stdout.next().then(expectAsync((line) { |
74 expect(line, contains("+1: test2.dart: success")); | 76 expect(line, contains("+1: test2.dart: success")); |
75 nextLineFired = true; | 77 nextLineFired = true; |
76 })); | 78 })); |
77 | 79 |
78 // Wait a little bit to be sure that the tests don't start running without | 80 // Wait a little bit to be sure that the tests don't start running without |
(...skipping 16 matching lines...) Expand all Loading... |
95 print('loaded test!'); | 97 print('loaded test!'); |
96 | 98 |
97 test("success", () {}); | 99 test("success", () {}); |
98 } | 100 } |
99 """).create(); | 101 """).create(); |
100 | 102 |
101 var test = runTest( | 103 var test = runTest( |
102 ["--pause-after-load", "-p", "dartium", "-p", "chrome", "test.dart"]); | 104 ["--pause-after-load", "-p", "dartium", "-p", "chrome", "test.dart"]); |
103 test.stdout.expect(consumeThrough("loaded test!")); | 105 test.stdout.expect(consumeThrough("loaded test!")); |
104 test.stdout.expect(consumeThrough(inOrder([ | 106 test.stdout.expect(consumeThrough(inOrder([ |
105 "The test runner is paused. Open the dev console in Dartium and set " | 107 startsWith("Observatory URL: "), |
106 "breakpoints. Once you're", | 108 "The test runner is paused. Open the dev console in Dartium or the " |
107 "finished, return to this terminal and press Enter." | 109 "Observatory and set breakpoints.", |
| 110 "Once you're finished, return to this terminal and press Enter." |
108 ]))); | 111 ]))); |
109 | 112 |
110 schedule(() async { | 113 schedule(() async { |
111 var nextLineFired = false; | 114 var nextLineFired = false; |
112 test.stdout.next().then(expectAsync((line) { | 115 test.stdout.next().then(expectAsync((line) { |
113 expect(line, contains("+0: [Dartium] success")); | 116 expect(line, contains("+0: [Dartium] success")); |
114 nextLineFired = true; | 117 nextLineFired = true; |
115 })); | 118 })); |
116 | 119 |
117 // Wait a little bit to be sure that the tests don't start running without | 120 // Wait a little bit to be sure that the tests don't start running without |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 test("prints a warning and doesn't pause for unsupported platforms", () { | 153 test("prints a warning and doesn't pause for unsupported platforms", () { |
151 d.file("test.dart", """ | 154 d.file("test.dart", """ |
152 import 'package:test/test.dart'; | 155 import 'package:test/test.dart'; |
153 | 156 |
154 void main() { | 157 void main() { |
155 test("success", () {}); | 158 test("success", () {}); |
156 } | 159 } |
157 """).create(); | 160 """).create(); |
158 | 161 |
159 var test = runTest( | 162 var test = runTest( |
160 ["--pause-after-load", "-p", "vm", "-p", "content-shell", "test.dart"]); | 163 ["--pause-after-load", "-p", "vm", "-p", "phantomjs", "test.dart"]); |
161 test.stderr.expect( | 164 test.stderr.expect( |
162 "Warning: Debugging is currently unsupported on the Dart VM and " | 165 "Warning: Debugging is currently unsupported on the Dart VM and " |
163 "Dartium Content Shell."); | 166 "PhantomJS."); |
164 test.stdout.expect(consumeThrough(contains("+2: All tests passed!"))); | 167 test.stdout.expect(consumeThrough(contains("+2: All tests passed!"))); |
165 test.shouldExit(0); | 168 test.shouldExit(0); |
166 }); | 169 }); |
167 | 170 |
168 test("can mix supported and unsupported platforms", () { | 171 test("can mix supported and unsupported platforms", () { |
169 d.file("test.dart", """ | 172 d.file("test.dart", """ |
170 import 'package:test/test.dart'; | 173 import 'package:test/test.dart'; |
171 | 174 |
172 void main() { | 175 void main() { |
173 print('loaded test!'); | 176 print('loaded test!'); |
174 | 177 |
175 test("success", () {}); | 178 test("success", () {}); |
176 } | 179 } |
177 """).create(); | 180 """).create(); |
178 | 181 |
179 var test = runTest( | 182 var test = runTest( |
180 ["--pause-after-load", "-p", "dartium", "-p", "vm", "test.dart"]); | 183 ["--pause-after-load", "-p", "dartium", "-p", "vm", "test.dart"]); |
181 test.stderr.expect( | 184 test.stderr.expect( |
182 "Warning: Debugging is currently unsupported on the Dart VM."); | 185 "Warning: Debugging is currently unsupported on the Dart VM."); |
183 | 186 |
184 test.stdout.expect(consumeThrough("loaded test!")); | 187 test.stdout.expect(consumeThrough("loaded test!")); |
185 test.stdout.expect(consumeThrough(inOrder([ | 188 test.stdout.expect(consumeThrough(inOrder([ |
186 "The test runner is paused. Open the dev console in Dartium and set " | 189 startsWith("Observatory URL: "), |
187 "breakpoints. Once you're", | 190 "The test runner is paused. Open the dev console in Dartium or the " |
188 "finished, return to this terminal and press Enter." | 191 "Observatory and set breakpoints.", |
| 192 "Once you're finished, return to this terminal and press Enter." |
189 ]))); | 193 ]))); |
190 | 194 |
191 schedule(() async { | 195 schedule(() async { |
192 var nextLineFired = false; | 196 var nextLineFired = false; |
193 test.stdout.next().then(expectAsync((line) { | 197 test.stdout.next().then(expectAsync((line) { |
194 expect(line, contains("+0: [Dartium] success")); | 198 expect(line, contains("+0: [Dartium] success")); |
195 nextLineFired = true; | 199 nextLineFired = true; |
196 })); | 200 })); |
197 | 201 |
198 // Wait a little bit to be sure that the tests don't start running without | 202 // Wait a little bit to be sure that the tests don't start running without |
(...skipping 19 matching lines...) Expand all Loading... |
218 void main() { | 222 void main() { |
219 print('loaded test!'); | 223 print('loaded test!'); |
220 | 224 |
221 test("success", () {}); | 225 test("success", () {}); |
222 } | 226 } |
223 """).create(); | 227 """).create(); |
224 | 228 |
225 var test = runTest(["--pause-after-load", "-p", "dartium", "test.dart"]); | 229 var test = runTest(["--pause-after-load", "-p", "dartium", "test.dart"]); |
226 test.stdout.expect(consumeThrough("loaded test!")); | 230 test.stdout.expect(consumeThrough("loaded test!")); |
227 test.stdout.expect(consumeThrough(inOrder([ | 231 test.stdout.expect(consumeThrough(inOrder([ |
228 "The test runner is paused. Open the dev console in Dartium and set " | 232 startsWith("Observatory URL: "), |
229 "breakpoints. Once you're", | 233 "The test runner is paused. Open the dev console in Dartium or the " |
230 "finished, return to this terminal and press Enter." | 234 "Observatory and set breakpoints.", |
| 235 "Once you're finished, return to this terminal and press Enter." |
231 ]))); | 236 ]))); |
232 | 237 |
233 test.signal(ProcessSignal.SIGTERM); | 238 test.signal(ProcessSignal.SIGTERM); |
234 test.shouldExit(); | 239 test.shouldExit(); |
235 test.stderr.expect(isDone); | 240 test.stderr.expect(isDone); |
236 }, testOn: "!windows"); | 241 }, testOn: "!windows"); |
237 | 242 |
238 test("disables timeouts", () { | 243 test("disables timeouts", () { |
239 d.file("test.dart", """ | 244 d.file("test.dart", """ |
240 import 'package:test/test.dart'; | 245 import 'package:test/test.dart'; |
241 | 246 |
242 void main() { | 247 void main() { |
243 print('loaded test 1!'); | 248 print('loaded test 1!'); |
244 | 249 |
245 test("success", () {}, timeout: new Timeout(Duration.ZERO)); | 250 test("success", () {}, timeout: new Timeout(Duration.ZERO)); |
246 } | 251 } |
247 """).create(); | 252 """).create(); |
248 | 253 |
249 var test = runTest( | 254 var test = runTest( |
250 ["--pause-after-load", "-p", "dartium", "-n", "success", "test.dart"]); | 255 ["--pause-after-load", "-p", "dartium", "-n", "success", "test.dart"]); |
251 test.stdout.expect(consumeThrough("loaded test 1!")); | 256 test.stdout.expect(consumeThrough("loaded test 1!")); |
252 test.stdout.expect(consumeThrough(inOrder([ | 257 test.stdout.expect(consumeThrough(inOrder([ |
253 "The test runner is paused. Open the dev console in Dartium and set " | 258 startsWith("Observatory URL: "), |
254 "breakpoints. Once you're", | 259 "The test runner is paused. Open the dev console in Dartium or the " |
255 "finished, return to this terminal and press Enter." | 260 "Observatory and set breakpoints.", |
| 261 "Once you're finished, return to this terminal and press Enter." |
256 ]))); | 262 ]))); |
257 | 263 |
258 schedule(() async { | 264 schedule(() async { |
259 var nextLineFired = false; | 265 var nextLineFired = false; |
260 test.stdout.next().then(expectAsync((line) { | 266 test.stdout.next().then(expectAsync((line) { |
261 expect(line, contains("+0: success")); | 267 expect(line, contains("+0: success")); |
262 nextLineFired = true; | 268 nextLineFired = true; |
263 })); | 269 })); |
264 | 270 |
265 // Wait a little bit to be sure that the tests don't start running without | 271 // Wait a little bit to be sure that the tests don't start running without |
(...skipping 18 matching lines...) Expand all Loading... |
284 test("failure 1", () {}); | 290 test("failure 1", () {}); |
285 test("success", () {}); | 291 test("success", () {}); |
286 test("failure 2", () {}); | 292 test("failure 2", () {}); |
287 } | 293 } |
288 """).create(); | 294 """).create(); |
289 | 295 |
290 var test = runTest( | 296 var test = runTest( |
291 ["--pause-after-load", "-p", "dartium", "-n", "success", "test.dart"]); | 297 ["--pause-after-load", "-p", "dartium", "-n", "success", "test.dart"]); |
292 test.stdout.expect(consumeThrough("loaded test 1!")); | 298 test.stdout.expect(consumeThrough("loaded test 1!")); |
293 test.stdout.expect(consumeThrough(inOrder([ | 299 test.stdout.expect(consumeThrough(inOrder([ |
294 "The test runner is paused. Open the dev console in Dartium and set " | 300 startsWith("Observatory URL: "), |
295 "breakpoints. Once you're", | 301 "The test runner is paused. Open the dev console in Dartium or the " |
296 "finished, return to this terminal and press Enter." | 302 "Observatory and set breakpoints.", |
| 303 "Once you're finished, return to this terminal and press Enter." |
297 ]))); | 304 ]))); |
298 | 305 |
299 schedule(() async { | 306 schedule(() async { |
300 var nextLineFired = false; | 307 var nextLineFired = false; |
301 test.stdout.next().then(expectAsync((line) { | 308 test.stdout.next().then(expectAsync((line) { |
302 expect(line, contains("+0: success")); | 309 expect(line, contains("+0: success")); |
303 nextLineFired = true; | 310 nextLineFired = true; |
304 })); | 311 })); |
305 | 312 |
306 // Wait a little bit to be sure that the tests don't start running without | 313 // Wait a little bit to be sure that the tests don't start running without |
307 // our input. | 314 // our input. |
308 await new Future.delayed(new Duration(seconds: 2)); | 315 await new Future.delayed(new Duration(seconds: 2)); |
309 expect(nextLineFired, isFalse); | 316 expect(nextLineFired, isFalse); |
310 }); | 317 }); |
311 | 318 |
312 test.writeLine(''); | 319 test.writeLine(''); |
313 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); | 320 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); |
314 test.shouldExit(0); | 321 test.shouldExit(0); |
315 }); | 322 }); |
316 } | 323 } |
OLD | NEW |