| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 library analyzer.test.generated.gn_test; | 5 library analyzer.test.generated.gn_test; |
| 6 | 6 |
| 7 import 'package:analyzer/file_system/memory_file_system.dart'; | 7 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 8 import 'package:analyzer/src/generated/gn.dart'; | 8 import 'package:analyzer/src/generated/gn.dart'; |
| 9 import 'package:test/test.dart'; | 9 import 'package:test/test.dart'; |
| 10 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 10 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 11 | 11 |
| 12 main() { | 12 main() { |
| 13 defineReflectiveSuite(() { | 13 defineReflectiveSuite(() { |
| 14 defineReflectiveTests(GnWorkspaceTest); | 14 defineReflectiveTests(GnWorkspaceTest); |
| 15 }); | 15 }); |
| 16 } | 16 } |
| 17 | 17 |
| 18 @reflectiveTest | 18 @reflectiveTest |
| 19 class GnWorkspaceTest extends _BaseTest { | 19 class GnWorkspaceTest extends _BaseTest { |
| 20 void test_find_notAbsolute() { | 20 void test_find_inHost() { |
| 21 expect(() => GnWorkspace.find(provider, _p('not_absolute')), | 21 provider.newFolder(_p('/workspace/.jiri_root')); |
| 22 throwsArgumentError); | 22 provider.newFolder(_p('/workspace/some/code')); |
| 23 provider.newFile(_p('/workspace/some/code/pubspec.yaml'), ''); |
| 24 provider.newFile( |
| 25 _p('/workspace/out/debug-x87_128/host_y32/gen/some/code/foo.packages'), |
| 26 ''); |
| 27 GnWorkspace workspace = |
| 28 GnWorkspace.find(provider, _p('/workspace/some/code')); |
| 29 expect(workspace, isNotNull); |
| 30 expect(workspace.root, _p('/workspace/some/code')); |
| 23 } | 31 } |
| 24 | 32 |
| 25 void test_find_noJiriRoot() { | 33 void test_find_noJiriRoot() { |
| 26 provider.newFolder(_p('/workspace')); | 34 provider.newFolder(_p('/workspace')); |
| 27 GnWorkspace workspace = GnWorkspace.find(provider, _p('/workspace')); | 35 GnWorkspace workspace = GnWorkspace.find(provider, _p('/workspace')); |
| 28 expect(workspace, isNull); | 36 expect(workspace, isNull); |
| 29 } | 37 } |
| 30 | 38 |
| 39 void test_find_notAbsolute() { |
| 40 expect(() => GnWorkspace.find(provider, _p('not_absolute')), |
| 41 throwsArgumentError); |
| 42 } |
| 43 |
| 31 void test_find_withRoot() { | 44 void test_find_withRoot() { |
| 32 provider.newFolder(_p('/workspace/.jiri_root')); | 45 provider.newFolder(_p('/workspace/.jiri_root')); |
| 33 provider.newFolder(_p('/workspace/some/code')); | 46 provider.newFolder(_p('/workspace/some/code')); |
| 34 provider.newFile(_p('/workspace/some/code/pubspec.yaml'), ''); | 47 provider.newFile(_p('/workspace/some/code/pubspec.yaml'), ''); |
| 35 provider.newFile( | 48 provider.newFile( |
| 36 _p('/workspace/out/debug-x87_128/gen/some/code/foo.packages'), ''); | 49 _p('/workspace/out/debug-x87_128/gen/some/code/foo.packages'), ''); |
| 37 GnWorkspace workspace = | 50 GnWorkspace workspace = |
| 38 GnWorkspace.find(provider, _p('/workspace/some/code')); | 51 GnWorkspace.find(provider, _p('/workspace/some/code')); |
| 39 expect(workspace, isNotNull); | 52 expect(workspace, isNotNull); |
| 40 expect(workspace.root, _p('/workspace/some/code')); | |
| 41 } | |
| 42 | |
| 43 void test_find_inHost() { | |
| 44 provider.newFolder(_p('/workspace/.jiri_root')); | |
| 45 provider.newFolder(_p('/workspace/some/code')); | |
| 46 provider.newFile(_p('/workspace/some/code/pubspec.yaml'), ''); | |
| 47 provider.newFile( | |
| 48 _p('/workspace/out/debug-x87_128/host_y32/gen/some/code/foo.packages'), | |
| 49 ''); | |
| 50 GnWorkspace workspace = | |
| 51 GnWorkspace.find(provider, _p('/workspace/some/code')); | |
| 52 expect(workspace, isNotNull); | |
| 53 expect(workspace.root, _p('/workspace/some/code')); | 53 expect(workspace.root, _p('/workspace/some/code')); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void test_packages() { | 56 void test_packages() { |
| 57 provider.newFolder(_p('/workspace/.jiri_root')); | 57 provider.newFolder(_p('/workspace/.jiri_root')); |
| 58 provider.newFolder(_p('/workspace/some/code')); | 58 provider.newFolder(_p('/workspace/some/code')); |
| 59 provider.newFile(_p('/workspace/some/code/pubspec.yaml'), ''); | 59 provider.newFile(_p('/workspace/some/code/pubspec.yaml'), ''); |
| 60 String packageLocation = _p('/workspace/this/is/the/package'); | 60 String packageLocation = _p('/workspace/this/is/the/package'); |
| 61 Uri packageUri = provider.pathContext.toUri(packageLocation); | 61 Uri packageUri = provider.pathContext.toUri(packageLocation); |
| 62 provider.newFile( | 62 provider.newFile( |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 } | 95 } |
| 96 | 96 |
| 97 class _BaseTest { | 97 class _BaseTest { |
| 98 final MemoryResourceProvider provider = new MemoryResourceProvider(); | 98 final MemoryResourceProvider provider = new MemoryResourceProvider(); |
| 99 | 99 |
| 100 /** | 100 /** |
| 101 * Return the [provider] specific path for the given Posix [path]. | 101 * Return the [provider] specific path for the given Posix [path]. |
| 102 */ | 102 */ |
| 103 String _p(String path) => provider.convertPath(path); | 103 String _p(String path) => provider.convertPath(path); |
| 104 } | 104 } |
| OLD | NEW |