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 'package:scheduled_test/descriptor.dart' as d; | 7 import 'package:scheduled_test/descriptor.dart' as d; |
8 import 'package:scheduled_test/scheduled_stream.dart'; | 8 import 'package:scheduled_test/scheduled_stream.dart'; |
9 import 'package:scheduled_test/scheduled_test.dart'; | 9 import 'package:scheduled_test/scheduled_test.dart'; |
10 | 10 |
11 import '../io.dart'; | 11 import '../io.dart'; |
12 | 12 |
13 void main() { | 13 void main() { |
14 useSandbox(); | 14 useSandbox(); |
15 | 15 |
16 test("reports when no tests are run", () { | 16 test("reports when no tests are run", () { |
17 d.file("test.dart", "void main() {}").create(); | 17 d.file("test.dart", "void main() {}").create(); |
18 | 18 |
19 var test = runTest(["test.dart"], compact: true); | 19 var test = runTest(["test.dart"], reporter: "compact"); |
20 test.stdout.expect(consumeThrough(contains("No tests ran."))); | 20 test.stdout.expect(consumeThrough(contains("No tests ran."))); |
21 test.shouldExit(0); | 21 test.shouldExit(0); |
22 }); | 22 }); |
23 | 23 |
24 test("runs several successful tests and reports when each completes", () { | 24 test("runs several successful tests and reports when each completes", () { |
25 _expectReport(""" | 25 _expectReport(""" |
26 test('success 1', () {}); | 26 test('success 1', () {}); |
27 test('success 2', () {}); | 27 test('success 2', () {}); |
28 test('success 3', () {});""", | 28 test('success 3', () {});""", |
29 """ | 29 """ |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 d.file("test.dart", """ | 69 d.file("test.dart", """ |
70 import 'dart:async'; | 70 import 'dart:async'; |
71 | 71 |
72 import 'package:test/test.dart'; | 72 import 'package:test/test.dart'; |
73 | 73 |
74 void main() { | 74 void main() { |
75 test("failure", () => throw "oh no"); | 75 test("failure", () => throw "oh no"); |
76 } | 76 } |
77 """).create(); | 77 """).create(); |
78 | 78 |
79 var test = runTest(["--verbose-trace", "test.dart"], compact: true); | 79 var test = runTest(["--verbose-trace", "test.dart"], reporter: "compact"); |
80 test.stdout.expect(consumeThrough(contains("dart:isolate-patch"))); | 80 test.stdout.expect(consumeThrough(contains("dart:isolate-patch"))); |
81 test.shouldExit(1); | 81 test.shouldExit(1); |
82 }); | 82 }); |
83 | 83 |
84 test("runs failing tests along with successful tests", () { | 84 test("runs failing tests along with successful tests", () { |
85 _expectReport(""" | 85 _expectReport(""" |
86 test('failure 1', () => throw new TestFailure('oh no')); | 86 test('failure 1', () => throw new TestFailure('oh no')); |
87 test('success 1', () {}); | 87 test('success 1', () {}); |
88 test('failure 2', () => throw new TestFailure('oh no')); | 88 test('failure 2', () => throw new TestFailure('oh no')); |
89 test('success 2', () {});""", | 89 test('success 2', () {});""", |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 | 399 |
400 import 'package:test/test.dart'; | 400 import 'package:test/test.dart'; |
401 | 401 |
402 void main() { | 402 void main() { |
403 $tests | 403 $tests |
404 } | 404 } |
405 """; | 405 """; |
406 | 406 |
407 d.file("test.dart", dart).create(); | 407 d.file("test.dart", dart).create(); |
408 | 408 |
409 var test = runTest(["test.dart"], compact: true); | 409 var test = runTest(["test.dart"], reporter: "compact"); |
410 test.shouldExit(); | 410 test.shouldExit(); |
411 | 411 |
412 schedule(() async { | 412 schedule(() async { |
413 var stdoutLines = await test.stdoutStream().toList(); | 413 var stdoutLines = await test.stdoutStream().toList(); |
414 | 414 |
415 // Skip the first CR, remove excess trailing whitespace, and trim off | 415 // Skip the first CR, remove excess trailing whitespace, and trim off |
416 // timestamps. | 416 // timestamps. |
417 var lastLine; | 417 var lastLine; |
418 var actual = stdoutLines.skip(1).map((line) { | 418 var actual = stdoutLines.skip(1).map((line) { |
419 if (line.startsWith(" ") || line.isEmpty) return line.trimRight(); | 419 if (line.startsWith(" ") || line.isEmpty) return line.trimRight(); |
(...skipping 11 matching lines...) Expand all Loading... |
431 // Un-indent the expected string. | 431 // Un-indent the expected string. |
432 var indentation = expected.indexOf(new RegExp("[^ ]")); | 432 var indentation = expected.indexOf(new RegExp("[^ ]")); |
433 expected = expected.split("\n").map((line) { | 433 expected = expected.split("\n").map((line) { |
434 if (line.isEmpty) return line; | 434 if (line.isEmpty) return line; |
435 return line.substring(indentation); | 435 return line.substring(indentation); |
436 }).join("\n"); | 436 }).join("\n"); |
437 | 437 |
438 expect(actual, equals(expected)); | 438 expect(actual, equals(expected)); |
439 }); | 439 }); |
440 } | 440 } |
OLD | NEW |