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 import 'dart:math' as math; | 8 import 'dart:math' as math; |
9 | 9 |
10 import 'package:path/path.dart' as p; | |
11 import 'package:scheduled_test/descriptor.dart' as d; | 10 import 'package:scheduled_test/descriptor.dart' as d; |
12 import 'package:scheduled_test/scheduled_stream.dart'; | 11 import 'package:scheduled_test/scheduled_stream.dart'; |
13 import 'package:scheduled_test/scheduled_test.dart'; | 12 import 'package:scheduled_test/scheduled_test.dart'; |
14 import 'package:test/src/util/exit_codes.dart' as exit_codes; | 13 import 'package:test/src/util/exit_codes.dart' as exit_codes; |
15 | 14 |
16 import '../io.dart'; | 15 import '../io.dart'; |
17 | 16 |
18 final _success = """ | 17 final _success = """ |
19 import 'dart:async'; | 18 import 'dart:async'; |
20 | 19 |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 return d.file("${i}_test.dart", _success); | 273 return d.file("${i}_test.dart", _success); |
275 })).create(); | 274 })).create(); |
276 | 275 |
277 var test = runTest([]); | 276 var test = runTest([]); |
278 test.stdout.expect(consumeThrough(contains("+3: All tests passed!"))); | 277 test.stdout.expect(consumeThrough(contains("+3: All tests passed!"))); |
279 test.shouldExit(0); | 278 test.shouldExit(0); |
280 }); | 279 }); |
281 | 280 |
282 test("directly", () { | 281 test("directly", () { |
283 d.file("test.dart", _success).create(); | 282 d.file("test.dart", _success).create(); |
284 var test = runDart([ | 283 var test = runDart(["test.dart"]); |
285 "--package-root=${p.join(packageDir, 'packages')}", | |
286 "test.dart" | |
287 ]); | |
288 | 284 |
289 test.stdout.expect(consumeThrough(contains("All tests passed!"))); | 285 test.stdout.expect(consumeThrough(contains("All tests passed!"))); |
290 test.shouldExit(0); | 286 test.shouldExit(0); |
291 }); | 287 }); |
292 | 288 |
293 // Regression test; this broke in 0.12.0-beta.9. | 289 // Regression test; this broke in 0.12.0-beta.9. |
294 test("on a file in a subdirectory", () { | 290 test("on a file in a subdirectory", () { |
295 d.dir("dir", [d.file("test.dart", _success)]).create(); | 291 d.dir("dir", [d.file("test.dart", _success)]).create(); |
296 | 292 |
297 var test = runTest(["dir/test.dart"]); | 293 var test = runTest(["dir/test.dart"]); |
(...skipping 26 matching lines...) Expand all Loading... |
324 return d.file("${i}_test.dart", _failure); | 320 return d.file("${i}_test.dart", _failure); |
325 })).create(); | 321 })).create(); |
326 | 322 |
327 var test = runTest([]); | 323 var test = runTest([]); |
328 test.stdout.expect(consumeThrough(contains("-3: Some tests failed."))); | 324 test.stdout.expect(consumeThrough(contains("-3: Some tests failed."))); |
329 test.shouldExit(1); | 325 test.shouldExit(1); |
330 }); | 326 }); |
331 | 327 |
332 test("directly", () { | 328 test("directly", () { |
333 d.file("test.dart", _failure).create(); | 329 d.file("test.dart", _failure).create(); |
334 var test = runDart([ | 330 var test = runDart(["test.dart"]); |
335 "--package-root=${p.join(packageDir, 'packages')}", | |
336 "test.dart" | |
337 ]); | |
338 test.stdout.expect(consumeThrough(contains("Some tests failed."))); | 331 test.stdout.expect(consumeThrough(contains("Some tests failed."))); |
339 test.shouldExit(255); | 332 test.shouldExit(255); |
340 }); | 333 }); |
341 }); | 334 }); |
342 | 335 |
343 test("runs tests even when a file fails to load", () { | 336 test("runs tests even when a file fails to load", () { |
344 d.file("test.dart", _success).create(); | 337 d.file("test.dart", _success).create(); |
345 | 338 |
346 var test = runTest(["test.dart", "nonexistent.dart"]); | 339 var test = runTest(["test.dart", "nonexistent.dart"]); |
347 test.stdout.expect(consumeThrough(contains("+1 -1: Some tests failed."))); | 340 test.stdout.expect(consumeThrough(contains("+1 -1: Some tests failed."))); |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 d.file("test.dart", _success).create(); | 666 d.file("test.dart", _success).create(); |
674 | 667 |
675 var test = runTest(["--plain-name", "no match", "test.dart"]); | 668 var test = runTest(["--plain-name", "no match", "test.dart"]); |
676 test.stderr.expect( | 669 test.stderr.expect( |
677 consumeThrough(contains('No tests match "no match".'))); | 670 consumeThrough(contains('No tests match "no match".'))); |
678 test.shouldExit(exit_codes.data); | 671 test.shouldExit(exit_codes.data); |
679 }); | 672 }); |
680 }); | 673 }); |
681 }); | 674 }); |
682 } | 675 } |
OLD | NEW |