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:io'; | 7 import 'dart:io'; |
8 | 8 |
9 import 'package:path/path.dart' as p; | 9 import 'package:path/path.dart' as p; |
10 import 'package:test/src/util/io.dart'; | 10 import 'package:test/src/util/io.dart'; |
11 import 'package:test/test.dart'; | 11 import 'package:test/test.dart'; |
12 | 12 |
13 import '../io.dart'; | 13 import '../io.dart'; |
14 | 14 |
15 void main() { | 15 void main() { |
16 test("reports when no tests are run", () { | 16 test("reports when no tests are run", () { |
17 return withTempDir((path) { | 17 return withTempDir((path) { |
18 new File(p.join(path, "test.dart")).writeAsStringSync("void main() {}"); | 18 new File(p.join(path, "test.dart")).writeAsStringSync("void main() {}"); |
19 var result = runUnittest(["test.dart"], workingDirectory: path); | 19 var result = runTest(["test.dart"], workingDirectory: path); |
20 expect(result.stdout, equals("No tests ran.\n")); | 20 expect(result.stdout, equals("No tests ran.\n")); |
21 }); | 21 }); |
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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 void main() { | 327 void main() { |
328 $tests | 328 $tests |
329 } | 329 } |
330 """; | 330 """; |
331 | 331 |
332 expect(withTempDir((path) { | 332 expect(withTempDir((path) { |
333 new File(p.join(path, "test.dart")).writeAsStringSync(dart); | 333 new File(p.join(path, "test.dart")).writeAsStringSync(dart); |
334 if (args == null) args = []; | 334 if (args == null) args = []; |
335 args = args.toList()..add("test.dart"); | 335 args = args.toList()..add("test.dart"); |
336 args.add("--concurrency=$concurrency"); | 336 args.add("--concurrency=$concurrency"); |
337 var result = runUnittest(args, workingDirectory: path); | 337 var result = runTest(args, workingDirectory: path); |
338 | 338 |
339 // Convert CRs into newlines, remove excess trailing whitespace, and trim | 339 // Convert CRs into newlines, remove excess trailing whitespace, and trim |
340 // off timestamps. | 340 // off timestamps. |
341 var actual = result.stdout.trim().split(new RegExp(r"[\r\n]")).map((line) { | 341 var actual = result.stdout.trim().split(new RegExp(r"[\r\n]")).map((line) { |
342 if (line.startsWith(" ") || line.isEmpty) return line.trimRight(); | 342 if (line.startsWith(" ") || line.isEmpty) return line.trimRight(); |
343 return line.trim().replaceFirst(new RegExp("^[0-9]{2}:[0-9]{2} "), ""); | 343 return line.trim().replaceFirst(new RegExp("^[0-9]{2}:[0-9]{2} "), ""); |
344 }).join("\n"); | 344 }).join("\n"); |
345 | 345 |
346 // Un-indent the expected string. | 346 // Un-indent the expected string. |
347 var indentation = expected.indexOf(new RegExp("[^ ]")); | 347 var indentation = expected.indexOf(new RegExp("[^ ]")); |
348 expected = expected.split("\n").map((line) { | 348 expected = expected.split("\n").map((line) { |
349 if (line.isEmpty) return line; | 349 if (line.isEmpty) return line; |
350 return line.substring(indentation); | 350 return line.substring(indentation); |
351 }).join("\n"); | 351 }).join("\n"); |
352 | 352 |
353 expect(actual, equals(expected)); | 353 expect(actual, equals(expected)); |
354 }), completes); | 354 }), completes); |
355 } | 355 } |
OLD | NEW |