| 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/exit_codes.dart' as exit_codes; | |
| 11 import 'package:test/src/util/io.dart'; | 10 import 'package:test/src/util/io.dart'; |
| 12 import 'package:test/test.dart'; | 11 import 'package:test/test.dart'; |
| 13 | 12 |
| 14 import '../../io.dart'; | 13 import '../../io.dart'; |
| 15 | 14 |
| 16 String _sandbox; | 15 String _sandbox; |
| 17 | 16 |
| 18 void main() { | 17 void main() { |
| 19 setUp(() { | 18 setUp(() { |
| 20 _sandbox = createTempDir(); | 19 _sandbox = createTempDir(); |
| 21 }); | 20 }); |
| 22 | 21 |
| 23 tearDown(() { | 22 tearDown(() { |
| 24 new Directory(_sandbox).deleteSync(recursive: true); | 23 new Directory(_sandbox).deleteSync(recursive: true); |
| 25 }); | 24 }); |
| 26 | 25 |
| 27 test("doesn't intermingle warnings", () { | 26 test("doesn't intermingle warnings", () { |
| 28 // These files need trailing newlines to work around issue 22667. | 27 // These files need trailing newlines to work around issue 22667. |
| 29 var testPath1 = p.join(_sandbox, "test1.dart"); | 28 var testPath1 = p.join(_sandbox, "test1.dart"); |
| 30 new File(testPath1).writeAsStringSync("String main() => 12;\n"); | 29 new File(testPath1).writeAsStringSync("String main() => 12;\n"); |
| 31 | 30 |
| 32 var testPath2 = p.join(_sandbox, "test2.dart"); | 31 var testPath2 = p.join(_sandbox, "test2.dart"); |
| 33 new File(testPath2).writeAsStringSync("int main() => 'foo';\n"); | 32 new File(testPath2).writeAsStringSync("int main() => 'foo';\n"); |
| 34 | 33 |
| 35 var result = _runUnittest(["-p", "chrome", "test1.dart", "test2.dart"]); | 34 var result = _runUnittest(["-p", "chrome", "test1.dart", "test2.dart"]); |
| 36 expect(result.stdout, equals(""" | 35 expect(result.stdout, startsWith(""" |
| 37 Compiling test1.dart... | 36 Compiling test1.dart... |
| 38 test1.dart:1:18: | 37 test1.dart:1:18: |
| 39 Warning: 'int' is not assignable to 'String'. | 38 Warning: 'int' is not assignable to 'String'. |
| 40 String main() => 12; | 39 String main() => 12; |
| 41 ^^ | 40 ^^ |
| 42 Compiling test2.dart... | 41 Compiling test2.dart... |
| 43 test2.dart:1:15: | 42 test2.dart:1:15: |
| 44 Warning: 'String' is not assignable to 'int'. | 43 Warning: 'String' is not assignable to 'int'. |
| 45 int main() => 'foo'; | 44 int main() => 'foo'; |
| 46 ^^^^^ | 45 ^^^^^ |
| 47 """)); | 46 """)); |
| 48 expect(result.exitCode, equals(exit_codes.data)); | 47 expect(result.exitCode, equals(1)); |
| 49 }); | 48 }); |
| 50 | 49 |
| 51 test("uses colors if the test runner uses colors", () { | 50 test("uses colors if the test runner uses colors", () { |
| 52 var testPath = p.join(_sandbox, "test.dart"); | 51 var testPath = p.join(_sandbox, "test.dart"); |
| 53 new File(testPath).writeAsStringSync("String main() => 12;\n"); | 52 new File(testPath).writeAsStringSync("String main() => 12;\n"); |
| 54 | 53 |
| 55 var result = _runUnittest(["--color", "-p", "chrome", "test.dart"]); | 54 var result = _runUnittest(["--color", "-p", "chrome", "test.dart"]); |
| 56 expect(result.stdout, contains('\u001b[35m')); | 55 expect(result.stdout, contains('\u001b[35m')); |
| 57 expect(result.exitCode, equals(exit_codes.data)); | 56 expect(result.exitCode, equals(1)); |
| 58 }); | 57 }); |
| 59 } | 58 } |
| 60 | 59 |
| 61 ProcessResult _runUnittest(List<String> args) => | 60 ProcessResult _runUnittest(List<String> args) => |
| 62 runUnittest(args, workingDirectory: _sandbox); | 61 runUnittest(args, workingDirectory: _sandbox); |
| OLD | NEW |