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 @Tags(const ["chrome"]) | 6 @Tags(const ["chrome"]) |
7 | 7 |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 | 9 |
10 import 'package:path/path.dart' as p; | 10 import 'package:path/path.dart' as p; |
(...skipping 16 matching lines...) Expand all Loading... |
27 import 'package:test/test.dart'; | 27 import 'package:test/test.dart'; |
28 | 28 |
29 void main() { | 29 void main() { |
30 test("success", () {}); | 30 test("success", () {}); |
31 test("failure", () => throw new TestFailure('oh no')); | 31 test("failure", () => throw new TestFailure('oh no')); |
32 test("error", () => throw 'oh no'); | 32 test("error", () => throw 'oh no'); |
33 } | 33 } |
34 """; | 34 """; |
35 | 35 |
36 void main() { | 36 void main() { |
37 setUp(() { | 37 setUp(() async { |
38 _sandbox = createTempDir(); | 38 _sandbox = createTempDir(); |
39 _loader = new Loader(new Configuration( | 39 _loader = new Loader(new Configuration(platforms: [TestPlatform.chrome]), |
40 platforms: [TestPlatform.chrome], | |
41 packageRoot: p.join(packageDir, 'packages')), | |
42 root: _sandbox); | 40 root: _sandbox); |
43 /// TODO(nweiz): Use scheduled_test for this once it's compatible with this | 41 /// TODO(nweiz): Use scheduled_test for this once it's compatible with this |
44 /// version of test. | 42 /// version of test. |
45 new File(p.join(_sandbox, 'a_test.dart')).writeAsStringSync(_tests); | 43 new File(p.join(_sandbox, 'a_test.dart')).writeAsStringSync(_tests); |
46 }); | 44 }); |
47 | 45 |
48 tearDown(() { | 46 tearDown(() { |
49 new Directory(_sandbox).deleteSync(recursive: true); | 47 new Directory(_sandbox).deleteSync(recursive: true); |
50 return _loader.close(); | 48 return _loader.close(); |
51 }); | 49 }); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 var loadSuite = suites.first; | 118 var loadSuite = suites.first; |
121 var suite = await loadSuite.getSuite(); | 119 var suite = await loadSuite.getSuite(); |
122 expect(suite.group.entries, hasLength(3)); | 120 expect(suite.group.entries, hasLength(3)); |
123 expect(suite.group.entries[0].name, equals("success")); | 121 expect(suite.group.entries[0].name, equals("success")); |
124 expect(suite.group.entries[1].name, equals("failure")); | 122 expect(suite.group.entries[1].name, equals("failure")); |
125 expect(suite.group.entries[2].name, equals("error")); | 123 expect(suite.group.entries[2].name, equals("error")); |
126 }); | 124 }); |
127 | 125 |
128 test("loads a suite both in the browser and the VM", () async { | 126 test("loads a suite both in the browser and the VM", () async { |
129 var loader = new Loader( | 127 var loader = new Loader( |
130 new Configuration( | 128 new Configuration(platforms: [TestPlatform.vm, TestPlatform.chrome]), |
131 platforms: [TestPlatform.vm, TestPlatform.chrome], | |
132 packageRoot: p.join(packageDir, 'packages')), | |
133 root: _sandbox); | 129 root: _sandbox); |
134 var path = p.join(_sandbox, 'a_test.dart'); | 130 var path = p.join(_sandbox, 'a_test.dart'); |
135 | 131 |
136 try { | 132 try { |
137 var suites = await loader.loadFile(path) | 133 var suites = await loader.loadFile(path) |
138 .asyncMap((loadSuite) => loadSuite.getSuite()).toList(); | 134 .asyncMap((loadSuite) => loadSuite.getSuite()).toList(); |
139 expect(suites[0].platform, equals(TestPlatform.vm)); | 135 expect(suites[0].platform, equals(TestPlatform.vm)); |
140 expect(suites[0].path, equals(path)); | 136 expect(suites[0].path, equals(path)); |
141 expect(suites[1].platform, equals(TestPlatform.chrome)); | 137 expect(suites[1].platform, equals(TestPlatform.chrome)); |
142 expect(suites[1].path, equals(path)); | 138 expect(suites[1].path, equals(path)); |
(...skipping 20 matching lines...) Expand all Loading... |
163 expect(suites, hasLength(1)); | 159 expect(suites, hasLength(1)); |
164 var loadSuite = suites.first; | 160 var loadSuite = suites.first; |
165 | 161 |
166 var liveTest = await loadSuite.group.entries.single.load(loadSuite); | 162 var liveTest = await loadSuite.group.entries.single.load(loadSuite); |
167 expect(liveTest.onMessage.first.then((message) => message.text), | 163 expect(liveTest.onMessage.first.then((message) => message.text), |
168 completion(equals("print within test"))); | 164 completion(equals("print within test"))); |
169 await liveTest.run(); | 165 await liveTest.run(); |
170 expectTestPassed(liveTest); | 166 expectTestPassed(liveTest); |
171 }); | 167 }); |
172 } | 168 } |
OLD | NEW |