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'; |
(...skipping 13 matching lines...) Expand all Loading... |
24 }); | 24 }); |
25 | 25 |
26 test("doesn't intermingle warnings", () { | 26 test("doesn't intermingle warnings", () { |
27 // These files need trailing newlines to work around issue 22667. | 27 // These files need trailing newlines to work around issue 22667. |
28 var testPath1 = p.join(_sandbox, "test1.dart"); | 28 var testPath1 = p.join(_sandbox, "test1.dart"); |
29 new File(testPath1).writeAsStringSync("String main() => 12;\n"); | 29 new File(testPath1).writeAsStringSync("String main() => 12;\n"); |
30 | 30 |
31 var testPath2 = p.join(_sandbox, "test2.dart"); | 31 var testPath2 = p.join(_sandbox, "test2.dart"); |
32 new File(testPath2).writeAsStringSync("int main() => 'foo';\n"); | 32 new File(testPath2).writeAsStringSync("int main() => 'foo';\n"); |
33 | 33 |
34 var result = _runUnittest(["-p", "chrome", "test1.dart", "test2.dart"]); | 34 var result = _runTest(["-p", "chrome", "test1.dart", "test2.dart"]); |
35 expect(result.stdout, startsWith(""" | 35 expect(result.stdout, startsWith(""" |
36 Compiling test1.dart... | 36 Compiling test1.dart... |
37 test1.dart:1:18: | 37 test1.dart:1:18: |
38 Warning: 'int' is not assignable to 'String'. | 38 Warning: 'int' is not assignable to 'String'. |
39 String main() => 12; | 39 String main() => 12; |
40 ^^ | 40 ^^ |
41 Compiling test2.dart... | 41 Compiling test2.dart... |
42 test2.dart:1:15: | 42 test2.dart:1:15: |
43 Warning: 'String' is not assignable to 'int'. | 43 Warning: 'String' is not assignable to 'int'. |
44 int main() => 'foo'; | 44 int main() => 'foo'; |
45 ^^^^^ | 45 ^^^^^ |
46 """)); | 46 """)); |
47 expect(result.exitCode, equals(1)); | 47 expect(result.exitCode, equals(1)); |
48 }); | 48 }); |
49 | 49 |
50 test("uses colors if the test runner uses colors", () { | 50 test("uses colors if the test runner uses colors", () { |
51 var testPath = p.join(_sandbox, "test.dart"); | 51 var testPath = p.join(_sandbox, "test.dart"); |
52 new File(testPath).writeAsStringSync("String main() => 12;\n"); | 52 new File(testPath).writeAsStringSync("String main() => 12;\n"); |
53 | 53 |
54 var result = _runUnittest(["--color", "-p", "chrome", "test.dart"]); | 54 var result = _runTest(["--color", "-p", "chrome", "test.dart"]); |
55 expect(result.stdout, contains('\u001b[35m')); | 55 expect(result.stdout, contains('\u001b[35m')); |
56 expect(result.exitCode, equals(1)); | 56 expect(result.exitCode, equals(1)); |
57 }); | 57 }); |
58 } | 58 } |
59 | 59 |
60 ProcessResult _runUnittest(List<String> args) => | 60 ProcessResult _runTest(List<String> args) => |
61 runUnittest(args, workingDirectory: _sandbox); | 61 runTest(args, workingDirectory: _sandbox); |
OLD | NEW |