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 |
| 5 // TODO(jakemac): swap this to @TestOn('pub-serve') once |
| 6 // https://github.com/dart-lang/test/issues/388 is completed. |
| 7 @TestOn('!js') |
4 @initializeTracker | 8 @initializeTracker |
5 library initialize.test.initializer_from_test; | 9 library initialize.test.initializer_from_test; |
6 | 10 |
7 import 'package:initialize/src/initialize_tracker.dart'; | 11 import 'package:initialize/src/initialize_tracker.dart'; |
8 import 'package:initialize/initialize.dart'; | 12 import 'package:initialize/initialize.dart'; |
9 import 'package:unittest/unittest.dart'; | 13 import 'package:test/test.dart'; |
10 import 'package:unittest/compact_vm_config.dart'; | 14 import 'package:test_package/bar.dart' as bar; |
11 import 'package:test_package/bar.dart'; // Used for annotations | |
12 | 15 |
| 16 /// Uses [bar] |
13 main() { | 17 main() { |
14 useCompactVMConfiguration(); | 18 test('The `from` option', () async { |
| 19 final expectedNames = <LibraryIdentifier>[]; |
15 | 20 |
16 test('The `from` option', () { | 21 // First just run on the test packages bar.dart file. |
17 var expectedNames = []; | 22 await run(from: Uri.parse('package:test_package/bar.dart')); |
18 return run(from: Uri.parse('package:test_package/bar.dart')).then((_) { | 23 expectedNames.add( |
19 // First just run on the test packages bar.dart file. | 24 const LibraryIdentifier(#test_package.bar, 'test_package', 'bar.dart')); |
20 expectedNames.add(const LibraryIdentifier( | 25 expect(InitializeTracker.seen, expectedNames); |
21 #test_package.bar, 'test_package', 'bar.dart')); | 26 |
22 expect(InitializeTracker.seen, expectedNames); | 27 // Now we run on the rest (just this file). |
23 }).then((_) => run()).then((_) { | 28 await run(); |
24 // Now we run on the rest (just this file). | 29 expect(InitializeTracker.seen.length, 2); |
25 expectedNames.add(const LibraryIdentifier( | 30 // Don't know what the path will be, so have to explicitly check fields |
26 #initialize.test.initializer_from_test, null, | 31 // and use an [endsWith] matcher for the path. |
27 'initializer_from_test.dart')); | 32 expect(InitializeTracker.seen[1].name, |
28 expect(InitializeTracker.seen, expectedNames); | 33 #initialize.test.initializer_from_test); |
29 }); | 34 expect(InitializeTracker.seen[1].package, isNull); |
30 }); | 35 expect( |
| 36 InitializeTracker.seen[1].path, endsWith('initializer_from_test.dart')); |
| 37 }, skip: 'Should be skipped only in pub-serve mode, blocked on ' |
| 38 'https://github.com/dart-lang/test/issues/388.'); |
31 } | 39 } |
OLD | NEW |