Chromium Code Reviews| Index: test/runner/expanded_reporter_test.dart |
| diff --git a/test/runner/expanded_reporter_test.dart b/test/runner/expanded_reporter_test.dart |
| index d22ad8d322474b4c64f3f1264679f7d6b6fa0935..2a3ba3ec6cfa2d61c66c9b57ff464ef57574cd64 100644 |
| --- a/test/runner/expanded_reporter_test.dart |
| +++ b/test/runner/expanded_reporter_test.dart |
| @@ -6,20 +6,22 @@ |
| import 'dart:io'; |
|
kevmoo
2015/07/22 04:10:12
now unused
nweiz
2015/07/22 18:35:48
Done.
|
| -import 'package:path/path.dart' as p; |
| +import 'package:scheduled_test/descriptor.dart' as d; |
| +import 'package:scheduled_test/scheduled_stream.dart'; |
| +import 'package:scheduled_test/scheduled_test.dart'; |
| import 'package:test/src/util/io.dart'; |
|
kevmoo
2015/07/22 04:10:12
now unused
nweiz
2015/07/22 18:35:48
Done.
|
| -import 'package:test/test.dart'; |
| import '../io.dart'; |
| void main() { |
| + useSandbox(); |
| + |
| test("reports when no tests are run", () { |
| - return withTempDir((path) { |
| - new File(p.join(path, "test.dart")).writeAsStringSync("void main() {}"); |
| - var result = runTest(["-r", "expanded", "test.dart"], |
| - workingDirectory: path); |
| - expect(result.stdout, contains("No tests ran.")); |
| - }); |
| + d.file("test.dart", "void main() {}").create(); |
| + |
| + var test = runTest(["test.dart"], compact: true); |
| + test.stdout.expect(consumeThrough(contains("No tests ran."))); |
| + test.shouldExit(0); |
| }); |
| test("runs several successful tests and reports when each completes", () { |
| @@ -59,8 +61,7 @@ void main() { |
| }); |
| test("includes the full stack trace with --verbose-trace", () { |
| - return withTempDir((path) { |
| - new File(p.join(path, "test.dart")).writeAsStringSync(""" |
| + d.file("test.dart", """ |
| import 'dart:async'; |
| import 'package:test/test.dart'; |
| @@ -68,11 +69,11 @@ import 'package:test/test.dart'; |
| void main() { |
| test("failure", () => throw "oh no"); |
| } |
| -"""); |
| - var result = runTest(["-r", "compact", "--verbose-trace", "test.dart"], |
| - workingDirectory: path); |
| - expect(result.stdout, contains("dart:isolate-patch")); |
| - }); |
| +""").create(); |
| + |
| + var test = runTest(["--verbose-trace", "test.dart"], compact: true); |
| + test.stdout.expect(consumeThrough(contains("dart:isolate-patch"))); |
| + test.shouldExit(1); |
| }); |
| test("runs failing tests along with successful tests", () { |
| @@ -309,10 +310,7 @@ void main() { |
| }); |
| } |
| -void _expectReport(String tests, String expected, {List<String> args, |
| - int concurrency}) { |
| - if (concurrency == null) concurrency = 1; |
| - |
| +void _expectReport(String tests, String expected) { |
| var dart = """ |
| import 'dart:async'; |
| @@ -323,17 +321,16 @@ $tests |
| } |
| """; |
| - expect(withTempDir((path) { |
| - new File(p.join(path, "test.dart")).writeAsStringSync(dart); |
| - if (args == null) args = []; |
| - args = args.toList() |
| - ..add("test.dart") |
| - ..add("--concurrency=$concurrency") |
| - ..add("--reporter=expanded"); |
| - var result = runTest(args, workingDirectory: path); |
| + d.file("test.dart", dart).create(); |
| + |
| + var test = runTest(["test.dart"]); |
| + test.shouldExit(); |
| + |
| + schedule(() async { |
| + var stdoutLines = await test.stdoutStream().toList(); |
| // Remove excess trailing whitespace and trim off timestamps. |
| - var actual = result.stdout.trim().split("\n").map((line) { |
| + var actual = stdoutLines.map((line) { |
| if (line.startsWith(" ") || line.isEmpty) return line.trimRight(); |
| return line.trim().replaceFirst(new RegExp("^[0-9]{2}:[0-9]{2} "), ""); |
| }).join("\n"); |
| @@ -346,5 +343,5 @@ $tests |
| }).join("\n"); |
| expect(actual, equals(expected)); |
| - }), completes); |
| + }); |
| } |