OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 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 | 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:convert'; | 8 import 'dart:convert'; |
8 | 9 |
9 import 'package:path/path.dart' as p; | 10 import 'package:path/path.dart' as p; |
10 import 'package:scheduled_test/descriptor.dart' as d; | 11 import 'package:scheduled_test/descriptor.dart' as d; |
11 import 'package:scheduled_test/scheduled_stream.dart'; | 12 import 'package:scheduled_test/scheduled_stream.dart'; |
12 import 'package:scheduled_test/scheduled_test.dart'; | 13 import 'package:scheduled_test/scheduled_test.dart'; |
13 import 'package:test/src/util/io.dart'; | 14 import 'package:test/src/util/io.dart'; |
14 | 15 |
15 import '../../io.dart'; | 16 import '../../io.dart'; |
16 | 17 |
17 void main() { | 18 void main() { |
18 useSandbox(); | 19 useSandbox(); |
19 | 20 |
20 test("ignores an empty file", () { | 21 test("ignores an empty file", () { |
21 d.file("dart_test.yaml", "").create(); | 22 d.file("dart_test.yaml", "").create(); |
22 | 23 |
23 d.file("test.dart", """ | 24 d.file("test.dart", """ |
24 import 'package:test/test.dart'; | 25 import 'package:test/test.dart'; |
25 | 26 |
26 void main() { | 27 void main() { |
27 test("success", () {}); | 28 test("success", () {}); |
28 } | 29 } |
29 """).create(); | 30 """).create(); |
30 | 31 |
31 var test = runTest(["test.dart"]); | 32 var test = runTest(["test.dart"]); |
32 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); | 33 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); |
33 test.shouldExit(0); | 34 test.shouldExit(0); |
34 }); | 35 }); |
35 | 36 |
| 37 test("pauses the test runner after a suite loads with pause_after_load: true", |
| 38 () { |
| 39 d.file("dart_test.yaml", JSON.encode({ |
| 40 "pause_after_load": true |
| 41 })).create(); |
| 42 |
| 43 d.file("test.dart", """ |
| 44 import 'package:test/test.dart'; |
| 45 |
| 46 void main() { |
| 47 print('loaded test!'); |
| 48 |
| 49 test("success", () {}); |
| 50 } |
| 51 """).create(); |
| 52 |
| 53 var test = runTest(["-p", "content-shell", "test.dart"]); |
| 54 test.stdout.expect(consumeThrough("loaded test!")); |
| 55 test.stdout.expect(inOrder([ |
| 56 "", |
| 57 startsWith("Observatory URL: "), |
| 58 startsWith("Remote debugger URL: "), |
| 59 "The test runner is paused. Open the remote debugger or the Observatory " |
| 60 "and set breakpoints. Once", |
| 61 "you're finished, return to this terminal and press Enter." |
| 62 ])); |
| 63 |
| 64 schedule(() async { |
| 65 var nextLineFired = false; |
| 66 test.stdout.next().then(expectAsync((line) { |
| 67 expect(line, contains("+0: success")); |
| 68 nextLineFired = true; |
| 69 })); |
| 70 |
| 71 // Wait a little bit to be sure that the tests don't start running without |
| 72 // our input. |
| 73 await new Future.delayed(new Duration(seconds: 2)); |
| 74 expect(nextLineFired, isFalse); |
| 75 }); |
| 76 |
| 77 test.writeLine(''); |
| 78 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); |
| 79 test.shouldExit(0); |
| 80 }, tags: 'content-shell'); |
| 81 |
36 test("includes the full stack with verbose_trace: true", () { | 82 test("includes the full stack with verbose_trace: true", () { |
37 d.file("dart_test.yaml", JSON.encode({ | 83 d.file("dart_test.yaml", JSON.encode({ |
38 "verbose_trace": true | 84 "verbose_trace": true |
39 })).create(); | 85 })).create(); |
40 | 86 |
41 d.file("test.dart", """ | 87 d.file("test.dart", """ |
42 import 'package:test/test.dart'; | 88 import 'package:test/test.dart'; |
43 | 89 |
44 void main() { | 90 void main() { |
45 test("failure", () => throw "oh no"); | 91 test("failure", () => throw "oh no"); |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 test("failure", () => throw "oh no"); | 535 test("failure", () => throw "oh no"); |
490 } | 536 } |
491 """) | 537 """) |
492 ]).create(); | 538 ]).create(); |
493 | 539 |
494 var test = runTest([]); | 540 var test = runTest([]); |
495 test.stdout.expect(consumeThrough(contains('All tests passed!'))); | 541 test.stdout.expect(consumeThrough(contains('All tests passed!'))); |
496 test.shouldExit(0); | 542 test.shouldExit(0); |
497 }); | 543 }); |
498 } | 544 } |
OLD | NEW |