| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 }); | 42 }); |
| 43 | 43 |
| 44 tearDown(() { | 44 tearDown(() { |
| 45 new Directory(_sandbox).deleteSync(recursive: true); | 45 new Directory(_sandbox).deleteSync(recursive: true); |
| 46 return _loader.close(); | 46 return _loader.close(); |
| 47 }); | 47 }); |
| 48 | 48 |
| 49 group(".loadFile()", () { | 49 group(".loadFile()", () { |
| 50 var suite; | 50 var suite; |
| 51 setUp(() { | 51 setUp(() { |
| 52 return _loader.loadFile(p.join(_sandbox, 'a_test.dart')).then((suites) { | 52 return _loader.loadFile(p.join(_sandbox, 'a_test.dart')).toList() |
| 53 .then((suites) { |
| 53 expect(suites, hasLength(1)); | 54 expect(suites, hasLength(1)); |
| 54 suite = suites.first; | 55 suite = suites.first; |
| 55 }); | 56 }); |
| 56 }); | 57 }); |
| 57 | 58 |
| 58 test("returns a suite with the file path and platform", () { | 59 test("returns a suite with the file path and platform", () { |
| 59 expect(suite.path, equals(p.join(_sandbox, 'a_test.dart'))); | 60 expect(suite.path, equals(p.join(_sandbox, 'a_test.dart'))); |
| 60 expect(suite.platform, equals('Chrome')); | 61 expect(suite.platform, equals('Chrome')); |
| 61 }); | 62 }); |
| 62 | 63 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 82 test("can load and run a failing test", () { | 83 test("can load and run a failing test", () { |
| 83 var liveTest = suite.tests[1].load(suite); | 84 var liveTest = suite.tests[1].load(suite); |
| 84 expectSingleFailure(liveTest); | 85 expectSingleFailure(liveTest); |
| 85 return liveTest.run().whenComplete(() => liveTest.close()); | 86 return liveTest.run().whenComplete(() => liveTest.close()); |
| 86 }); | 87 }); |
| 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", () { |
| 90 var loader = new Loader([TestPlatform.chrome]); | 91 var loader = new Loader([TestPlatform.chrome]); |
| 91 expect( | 92 expect( |
| 92 loader.loadFile(p.join(_sandbox, 'a_test.dart')) | 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 test("loads a suite both in the browser and the VM", () { | 99 test("loads a suite both in the browser and the VM", () { |
| 99 var loader = new Loader([TestPlatform.vm, TestPlatform.chrome], | 100 var loader = new Loader([TestPlatform.vm, TestPlatform.chrome], |
| 100 packageRoot: p.join(packageDir, 'packages')); | 101 packageRoot: p.join(packageDir, 'packages')); |
| 101 var path = p.join(_sandbox, 'a_test.dart'); | 102 var path = p.join(_sandbox, 'a_test.dart'); |
| 102 return loader.loadFile(path).then((suites) { | 103 return loader.loadFile(path).toList().then((suites) { |
| 103 expect(suites[0].platform, equals('VM')); | 104 expect(suites[0].platform, equals('VM')); |
| 104 expect(suites[0].path, equals(path)); | 105 expect(suites[0].path, equals(path)); |
| 105 expect(suites[1].platform, equals('Chrome')); | 106 expect(suites[1].platform, equals('Chrome')); |
| 106 expect(suites[1].path, equals(path)); | 107 expect(suites[1].path, equals(path)); |
| 107 | 108 |
| 108 for (var suite in suites) { | 109 for (var suite in suites) { |
| 109 expect(suite.tests, hasLength(3)); | 110 expect(suite.tests, hasLength(3)); |
| 110 expect(suite.tests[0].name, equals("success")); | 111 expect(suite.tests[0].name, equals("success")); |
| 111 expect(suite.tests[1].name, equals("failure")); | 112 expect(suite.tests[1].name, equals("failure")); |
| 112 expect(suite.tests[2].name, equals("error")); | 113 expect(suite.tests[2].name, equals("error")); |
| 113 } | 114 } |
| 114 }).whenComplete(loader.close); | 115 }).whenComplete(loader.close); |
| 115 }); | 116 }); |
| 116 } | 117 } |
| OLD | NEW |