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