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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 83 |
84 test("can load and run a failing test", () { | 84 test("can load and run a failing test", () { |
85 var liveTest = suite.tests[1].load(suite); | 85 var liveTest = suite.tests[1].load(suite); |
86 expectSingleFailure(liveTest); | 86 expectSingleFailure(liveTest); |
87 return liveTest.run().whenComplete(() => liveTest.close()); | 87 return liveTest.run().whenComplete(() => liveTest.close()); |
88 }); | 88 }); |
89 | 89 |
90 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", () { |
91 expect(() => new Loader([TestPlatform.chrome], root: _sandbox), | 91 expect(() => new Loader([TestPlatform.chrome], root: _sandbox), |
92 throwsA(isApplicationException( | 92 throwsA(isApplicationException( |
93 "Directory ${p.join(_sandbox, 'packages')} does not exist."))); | 93 "Directory ${p.prettyUri(p.toUri(p.join(_sandbox, 'packages')))} " |
| 94 "does not exist."))); |
94 }); | 95 }); |
95 }); | 96 }); |
96 | 97 |
97 group(".loadDir()", () { | 98 group(".loadDir()", () { |
98 test("ignores non-Dart files", () { | 99 test("ignores non-Dart files", () { |
99 new File(p.join(_sandbox, 'a_test.txt')).writeAsStringSync(_tests); | 100 new File(p.join(_sandbox, 'a_test.txt')).writeAsStringSync(_tests); |
100 expect(_loader.loadDir(_sandbox).toList(), completion(isEmpty)); | 101 expect(_loader.loadDir(_sandbox).toList(), completion(isEmpty)); |
101 }); | 102 }); |
102 | 103 |
103 test("ignores files in packages/ directories", () { | 104 test("ignores files in packages/ directories", () { |
(...skipping 21 matching lines...) Expand all Loading... |
125 .writeAsStringSync(_tests); | 126 .writeAsStringSync(_tests); |
126 | 127 |
127 return _loader.loadDir(_sandbox).toList() | 128 return _loader.loadDir(_sandbox).toList() |
128 .then((suites_) => suites = suites_); | 129 .then((suites_) => suites = suites_); |
129 }); | 130 }); |
130 | 131 |
131 test("gives those suites the correct paths", () { | 132 test("gives those suites the correct paths", () { |
132 expect(suites.map((suite) => suite.path), unorderedEquals([ | 133 expect(suites.map((suite) => suite.path), unorderedEquals([ |
133 p.join(_sandbox, 'a_test.dart'), | 134 p.join(_sandbox, 'a_test.dart'), |
134 p.join(_sandbox, 'another_test.dart'), | 135 p.join(_sandbox, 'another_test.dart'), |
135 p.join(_sandbox, 'dir/sub_test.dart') | 136 p.join(_sandbox, 'dir', 'sub_test.dart') |
136 ])); | 137 ])); |
137 }); | 138 }); |
138 | 139 |
139 test("can run tests in those suites", () { | 140 test("can run tests in those suites", () { |
140 var suite = suites.firstWhere((suite) => suite.path.contains("a_test")); | 141 var suite = suites.firstWhere((suite) => suite.path.contains("a_test")); |
141 var liveTest = suite.tests[1].load(suite); | 142 var liveTest = suite.tests[1].load(suite); |
142 expectSingleFailure(liveTest); | 143 expectSingleFailure(liveTest); |
143 return liveTest.run().whenComplete(() => liveTest.close()); | 144 return liveTest.run().whenComplete(() => liveTest.close()); |
144 }); | 145 }); |
145 }); | 146 }); |
146 }); | 147 }); |
147 } | 148 } |
OLD | NEW |