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:async'; | 7 import 'dart:async'; |
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 test.shouldExit(0); | 85 test.shouldExit(0); |
86 pub.kill(); | 86 pub.kill(); |
87 }); | 87 }); |
88 | 88 |
89 test("runs those tests on Chrome", () { | 89 test("runs those tests on Chrome", () { |
90 var pub = runPubServe(); | 90 var pub = runPubServe(); |
91 var test = runTest([_pubServeArg, '-p', 'chrome']); | 91 var test = runTest([_pubServeArg, '-p', 'chrome']); |
92 test.stdout.expect(consumeThrough(contains('+1: All tests passed!'))); | 92 test.stdout.expect(consumeThrough(contains('+1: All tests passed!'))); |
93 test.shouldExit(0); | 93 test.shouldExit(0); |
94 pub.kill(); | 94 pub.kill(); |
95 }); | 95 }, tags: 'chrome'); |
96 | 96 |
97 test("runs those tests on content shell", () { | 97 test("runs those tests on content shell", () { |
98 var pub = runPubServe(); | 98 var pub = runPubServe(); |
99 var test = runTest([_pubServeArg, '-p', 'content-shell']); | 99 var test = runTest([_pubServeArg, '-p', 'content-shell']); |
100 test.stdout.expect(consumeThrough(contains('+1: All tests passed!'))); | 100 test.stdout.expect(consumeThrough(contains('+1: All tests passed!'))); |
101 test.shouldExit(0); | 101 test.shouldExit(0); |
102 pub.kill(); | 102 pub.kill(); |
103 }); | 103 }, tags: 'content-shell'); |
104 | 104 |
105 test("gracefully handles pub serve running on the wrong directory for " | 105 test("gracefully handles pub serve running on the wrong directory for " |
106 "VM tests", () { | 106 "VM tests", () { |
107 d.dir("web").create(); | 107 d.dir("web").create(); |
108 | 108 |
109 var pub = runPubServe(args: ['web']); | 109 var pub = runPubServe(args: ['web']); |
110 var test = runTest([_pubServeArg]); | 110 var test = runTest([_pubServeArg]); |
111 test.stdout.expect(containsInOrder([ | 111 test.stdout.expect(containsInOrder([ |
112 '-1: loading ${p.join("test", "my_test.dart")}', | 112 '-1: loading ${p.join("test", "my_test.dart")}', |
113 'Failed to load "${p.join("test", "my_test.dart")}":', | 113 'Failed to load "${p.join("test", "my_test.dart")}":', |
(...skipping 14 matching lines...) Expand all Loading... |
128 var test = runTest([_pubServeArg, '-p', 'chrome']); | 128 var test = runTest([_pubServeArg, '-p', 'chrome']); |
129 test.stdout.expect(containsInOrder([ | 129 test.stdout.expect(containsInOrder([ |
130 '-1: compiling ${p.join("test", "my_test.dart")}', | 130 '-1: compiling ${p.join("test", "my_test.dart")}', |
131 'Failed to load "${p.join("test", "my_test.dart")}":', | 131 'Failed to load "${p.join("test", "my_test.dart")}":', |
132 '404 Not Found', | 132 '404 Not Found', |
133 'Make sure "pub serve" is serving the test/ directory.' | 133 'Make sure "pub serve" is serving the test/ directory.' |
134 ])); | 134 ])); |
135 test.shouldExit(1); | 135 test.shouldExit(1); |
136 | 136 |
137 pub.kill(); | 137 pub.kill(); |
138 }); | 138 }, tags: 'chrome'); |
139 | 139 |
140 test("when run on content shell", () { | 140 test("when run on content shell", () { |
141 d.dir("web").create(); | 141 d.dir("web").create(); |
142 | 142 |
143 var pub = runPubServe(args: ['web']); | 143 var pub = runPubServe(args: ['web']); |
144 var test = runTest([_pubServeArg, '-p', 'content-shell']); | 144 var test = runTest([_pubServeArg, '-p', 'content-shell']); |
145 test.stdout.expect(containsInOrder([ | 145 test.stdout.expect(containsInOrder([ |
146 '-1: loading ${p.join("test", "my_test.dart")}', | 146 '-1: loading ${p.join("test", "my_test.dart")}', |
147 'Failed to load "${p.join("test", "my_test.dart")}":', | 147 'Failed to load "${p.join("test", "my_test.dart")}":', |
148 '404 Not Found', | 148 '404 Not Found', |
149 'Make sure "pub serve" is serving the test/ directory.' | 149 'Make sure "pub serve" is serving the test/ directory.' |
150 ])); | 150 ])); |
151 test.shouldExit(1); | 151 test.shouldExit(1); |
152 | 152 |
153 pub.kill(); | 153 pub.kill(); |
154 }); | 154 }, tags: 'content-shell'); |
155 }); | 155 }); |
156 | 156 |
157 test("gracefully handles unconfigured transformers", () { | 157 test("gracefully handles unconfigured transformers", () { |
158 d.file("pubspec.yaml", """ | 158 d.file("pubspec.yaml", """ |
159 name: myapp | 159 name: myapp |
160 dependencies: | 160 dependencies: |
161 barback: any | 161 barback: any |
162 test: {path: ${p.current}} | 162 test: {path: ${p.current}} |
163 """).create(); | 163 """).create(); |
164 | 164 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 """) | 205 """) |
206 ]).create(); | 206 ]).create(); |
207 }); | 207 }); |
208 | 208 |
209 test("on Chrome", () { | 209 test("on Chrome", () { |
210 var pub = runPubServe(); | 210 var pub = runPubServe(); |
211 var test = runTest([_pubServeArg, '-p', 'chrome']); | 211 var test = runTest([_pubServeArg, '-p', 'chrome']); |
212 test.stdout.expect(consumeThrough(contains('+1: All tests passed!'))); | 212 test.stdout.expect(consumeThrough(contains('+1: All tests passed!'))); |
213 test.shouldExit(0); | 213 test.shouldExit(0); |
214 pub.kill(); | 214 pub.kill(); |
215 }); | 215 }, tags: 'chrome'); |
216 | 216 |
217 test("on content shell", () { | 217 test("on content shell", () { |
218 var pub = runPubServe(); | 218 var pub = runPubServe(); |
219 var test = runTest([_pubServeArg, '-p', 'content-shell']); | 219 var test = runTest([_pubServeArg, '-p', 'content-shell']); |
220 test.stdout.expect(consumeThrough(contains('+1: All tests passed!'))); | 220 test.stdout.expect(consumeThrough(contains('+1: All tests passed!'))); |
221 test.shouldExit(0); | 221 test.shouldExit(0); |
222 pub.kill(); | 222 pub.kill(); |
223 }); | 223 }, tags: 'content-shell'); |
224 }); | 224 }); |
225 | 225 |
226 group("with a failing test", () { | 226 group("with a failing test", () { |
227 setUp(() { | 227 setUp(() { |
228 d.file("test/my_test.dart", """ | 228 d.file("test/my_test.dart", """ |
229 import 'dart:html'; | 229 import 'dart:html'; |
230 | 230 |
231 import 'package:test/test.dart'; | 231 import 'package:test/test.dart'; |
232 | 232 |
233 void main() { | 233 void main() { |
234 test("failure", () => throw 'oh no'); | 234 test("failure", () => throw 'oh no'); |
235 } | 235 } |
236 """).create(); | 236 """).create(); |
237 }); | 237 }); |
238 | 238 |
239 test("dartifies stack traces for JS-compiled tests by default", () { | 239 test("dartifies stack traces for JS-compiled tests by default", () { |
240 var pub = runPubServe(); | 240 var pub = runPubServe(); |
241 var test = runTest([_pubServeArg, '-p', 'chrome', '--verbose-trace']); | 241 var test = runTest([_pubServeArg, '-p', 'chrome', '--verbose-trace']); |
242 test.stdout.expect(containsInOrder([ | 242 test.stdout.expect(containsInOrder([ |
243 " main.<fn>", | 243 " main.<fn>", |
244 "package:test", | 244 "package:test", |
245 "dart:async/zone.dart" | 245 "dart:async/zone.dart" |
246 ])); | 246 ])); |
247 test.shouldExit(1); | 247 test.shouldExit(1); |
248 pub.kill(); | 248 pub.kill(); |
249 }); | 249 }, tags: 'chrome'); |
250 | 250 |
251 test("doesn't dartify stack traces for JS-compiled tests with --js-trace", | 251 test("doesn't dartify stack traces for JS-compiled tests with --js-trace", |
252 () { | 252 () { |
253 var pub = runPubServe(); | 253 var pub = runPubServe(); |
254 var test = runTest([ | 254 var test = runTest([ |
255 _pubServeArg, | 255 _pubServeArg, |
256 '-p', 'chrome', | 256 '-p', 'chrome', |
257 '--js-trace', | 257 '--js-trace', |
258 '--verbose-trace' | 258 '--verbose-trace' |
259 ]); | 259 ]); |
260 | 260 |
261 test.stdout.fork().expect(never(endsWith(" main.<fn>"))); | 261 test.stdout.fork().expect(never(endsWith(" main.<fn>"))); |
262 test.stdout.fork().expect(never(contains("package:test"))); | 262 test.stdout.fork().expect(never(contains("package:test"))); |
263 test.stdout.fork().expect(never(contains("dart:async/zone.dart"))); | 263 test.stdout.fork().expect(never(contains("dart:async/zone.dart"))); |
264 test.stdout.expect(consumeThrough(contains("-1: Some tests failed."))); | 264 test.stdout.expect(consumeThrough(contains("-1: Some tests failed."))); |
265 test.shouldExit(1); | 265 test.shouldExit(1); |
266 | 266 |
267 pub.kill(); | 267 pub.kill(); |
268 }); | 268 }, tags: 'chrome'); |
269 }); | 269 }); |
270 | 270 |
271 test("gracefully handles pub serve not running for VM tests", () { | 271 test("gracefully handles pub serve not running for VM tests", () { |
272 var test = runTest(['--pub-serve=54321']); | 272 var test = runTest(['--pub-serve=54321']); |
273 test.stdout.expect(containsInOrder([ | 273 test.stdout.expect(containsInOrder([ |
274 '-1: loading ${p.join("test", "my_test.dart")}', | 274 '-1: loading ${p.join("test", "my_test.dart")}', |
275 'Failed to load "${p.join("test", "my_test.dart")}":', | 275 'Failed to load "${p.join("test", "my_test.dart")}":', |
276 'Error getting http://localhost:54321/my_test.dart.vm_test.dart: ' | 276 'Error getting http://localhost:54321/my_test.dart.vm_test.dart: ' |
277 'Connection refused', | 277 'Connection refused', |
278 'Make sure "pub serve" is running.' | 278 'Make sure "pub serve" is running.' |
279 ])); | 279 ])); |
280 test.shouldExit(1); | 280 test.shouldExit(1); |
281 }); | 281 }); |
282 | 282 |
283 test("gracefully handles pub serve not running for browser tests", () { | 283 test("gracefully handles pub serve not running for browser tests", () { |
284 var test = runTest(['--pub-serve=54321', '-p', 'chrome']); | 284 var test = runTest(['--pub-serve=54321', '-p', 'chrome']); |
285 var message = Platform.isWindows | 285 var message = Platform.isWindows |
286 ? 'The remote computer refused the network connection.' | 286 ? 'The remote computer refused the network connection.' |
287 : 'Connection refused (errno '; | 287 : 'Connection refused (errno '; |
288 | 288 |
289 test.stdout.expect(containsInOrder([ | 289 test.stdout.expect(containsInOrder([ |
290 '-1: compiling ${p.join("test", "my_test.dart")}', | 290 '-1: compiling ${p.join("test", "my_test.dart")}', |
291 'Failed to load "${p.join("test", "my_test.dart")}":', | 291 'Failed to load "${p.join("test", "my_test.dart")}":', |
292 'Error getting http://localhost:54321/my_test.dart.browser_test.dart.js' | 292 'Error getting http://localhost:54321/my_test.dart.browser_test.dart.js' |
293 '.map: $message', | 293 '.map: $message', |
294 'Make sure "pub serve" is running.' | 294 'Make sure "pub serve" is running.' |
295 ])); | 295 ])); |
296 test.shouldExit(1); | 296 test.shouldExit(1); |
297 }); | 297 }, tags: 'chrome'); |
298 | 298 |
299 test("gracefully handles a test file not being in test/", () { | 299 test("gracefully handles a test file not being in test/", () { |
300 schedule(() { | 300 schedule(() { |
301 new File(p.join(sandbox, 'test/my_test.dart')) | 301 new File(p.join(sandbox, 'test/my_test.dart')) |
302 .copySync(p.join(sandbox, 'my_test.dart')); | 302 .copySync(p.join(sandbox, 'my_test.dart')); |
303 }); | 303 }); |
304 | 304 |
305 var test = runTest(['--pub-serve=54321', 'my_test.dart']); | 305 var test = runTest(['--pub-serve=54321', 'my_test.dart']); |
306 test.stdout.expect(containsInOrder([ | 306 test.stdout.expect(containsInOrder([ |
307 '-1: loading my_test.dart', | 307 '-1: loading my_test.dart', |
308 'Failed to load "my_test.dart": When using "pub serve", all test files ' | 308 'Failed to load "my_test.dart": When using "pub serve", all test files ' |
309 'must be in test/.' | 309 'must be in test/.' |
310 ])); | 310 ])); |
311 test.shouldExit(1); | 311 test.shouldExit(1); |
312 }); | 312 }); |
313 } | 313 } |
OLD | NEW |