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/backend/state.dart'; | 10 import 'package:test/src/backend/state.dart'; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 | 26 |
| 27 void main() { | 27 void main() { |
| 28 test("success", () {}); | 28 test("success", () {}); |
| 29 test("failure", () => throw new TestFailure('oh no')); | 29 test("failure", () => throw new TestFailure('oh no')); |
| 30 test("error", () => throw 'oh no'); | 30 test("error", () => throw 'oh no'); |
| 31 } | 31 } |
| 32 """; | 32 """; |
| 33 | 33 |
| 34 void main() { | 34 void main() { |
| 35 setUp(() { | 35 setUp(() { |
| 36 _sandbox = createTempDir(); | |
| 36 _loader = new Loader([TestPlatform.vm], | 37 _loader = new Loader([TestPlatform.vm], |
| 38 root: _sandbox, | |
| 37 packageRoot: p.join(packageDir, 'packages')); | 39 packageRoot: p.join(packageDir, 'packages')); |
| 38 _sandbox = createTempDir(); | |
| 39 }); | 40 }); |
| 40 | 41 |
| 41 tearDown(() { | 42 tearDown(() { |
| 42 new Directory(_sandbox).deleteSync(recursive: true); | 43 new Directory(_sandbox).deleteSync(recursive: true); |
| 43 return _loader.close(); | 44 return _loader.close(); |
| 44 }); | 45 }); |
| 45 | 46 |
| 46 group(".loadFile()", () { | 47 group(".loadFile()", () { |
| 47 var suite; | 48 var suite; |
| 48 setUp(() { | 49 setUp(() { |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 79 | 80 |
| 80 return liveTest.run().whenComplete(() => liveTest.close()); | 81 return liveTest.run().whenComplete(() => liveTest.close()); |
| 81 }); | 82 }); |
| 82 | 83 |
| 83 test("can load and run a failing test", () { | 84 test("can load and run a failing test", () { |
| 84 var liveTest = suite.tests[1].load(suite); | 85 var liveTest = suite.tests[1].load(suite); |
| 85 expectSingleFailure(liveTest); | 86 expectSingleFailure(liveTest); |
| 86 return liveTest.run().whenComplete(() => liveTest.close()); | 87 return liveTest.run().whenComplete(() => liveTest.close()); |
| 87 }); | 88 }); |
| 88 | 89 |
| 89 test("throws a nice error if the package root doesn't exist", () { | 90 test("throws a nice error if the package root doesn't exist", () { |
|
kevmoo
2015/04/11 01:22:25
This times out for me on mac
using bleeding edge
| |
| 90 var loader = new Loader([TestPlatform.vm]); | 91 var loader = new Loader([TestPlatform.vm], root: _sandbox); |
| 91 expect( | 92 expect( |
| 92 loader.loadFile(p.join(_sandbox, 'a_test.dart')).first | 93 loader.loadFile(p.join(_sandbox, 'a_test.dart')).first |
| 93 .whenComplete(loader.close), | 94 .whenComplete(loader.close), |
| 94 throwsA(isLoadException( | 95 throwsA(isLoadException( |
| 95 "Directory ${p.join(_sandbox, 'packages')} does not exist."))); | 96 "Directory ${p.join(_sandbox, 'packages')} does not exist."))); |
| 96 }); | 97 }); |
| 97 }); | 98 }); |
| 98 | 99 |
| 99 group(".loadDir()", () { | 100 group(".loadDir()", () { |
| 100 test("ignores non-Dart files", () { | 101 test("ignores non-Dart files", () { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 | 141 |
| 141 test("can run tests in those suites", () { | 142 test("can run tests in those suites", () { |
| 142 var suite = suites.firstWhere((suite) => suite.path.contains("a_test")); | 143 var suite = suites.firstWhere((suite) => suite.path.contains("a_test")); |
| 143 var liveTest = suite.tests[1].load(suite); | 144 var liveTest = suite.tests[1].load(suite); |
| 144 expectSingleFailure(liveTest); | 145 expectSingleFailure(liveTest); |
| 145 return liveTest.run().whenComplete(() => liveTest.close()); | 146 return liveTest.run().whenComplete(() => liveTest.close()); |
| 146 }); | 147 }); |
| 147 }); | 148 }); |
| 148 }); | 149 }); |
| 149 } | 150 } |
| OLD | NEW |