fix multiroot scheme (#27914)
This commit is contained in:
parent
f1a8eed083
commit
537b592ed5
@ -131,7 +131,7 @@ class PackageUriMapper {
|
|||||||
if (fileSystemScheme != null && fileSystemRoots != null && prefix.contains(fileSystemScheme)) {
|
if (fileSystemScheme != null && fileSystemRoots != null && prefix.contains(fileSystemScheme)) {
|
||||||
_packageName = packageName;
|
_packageName = packageName;
|
||||||
_uriPrefixes = fileSystemRoots
|
_uriPrefixes = fileSystemRoots
|
||||||
.map((String name) => Uri.file('$name/lib/', windows: platform.isWindows).toString())
|
.map((String name) => Uri.file(name, windows: platform.isWindows).toString())
|
||||||
.toList();
|
.toList();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -65,12 +65,12 @@ example:file:///example/lib/
|
|||||||
const String multiRootPackagesContents = r'''
|
const String multiRootPackagesContents = r'''
|
||||||
xml:file:///Users/flutter_user/.pub-cache/hosted/pub.dartlang.org/xml-3.2.3/lib/
|
xml:file:///Users/flutter_user/.pub-cache/hosted/pub.dartlang.org/xml-3.2.3/lib/
|
||||||
yaml:file:///Users/flutter_user/.pub-cache/hosted/pub.dartlang.org/yaml-2.1.15/lib/
|
yaml:file:///Users/flutter_user/.pub-cache/hosted/pub.dartlang.org/yaml-2.1.15/lib/
|
||||||
example:org-dartlang-app:///lib/
|
example:org-dartlang-app:/
|
||||||
''';
|
''';
|
||||||
when(mockFile.readAsBytesSync()).thenReturn(utf8.encode(multiRootPackagesContents));
|
when(mockFile.readAsBytesSync()).thenReturn(utf8.encode(multiRootPackagesContents));
|
||||||
|
|
||||||
testUsingContext('Maps main file from same package on multiroot scheme', () async {
|
testUsingContext('Maps main file from same package on multiroot scheme', () async {
|
||||||
final PackageUriMapper packageUriMapper = PackageUriMapper('/example/lib/main.dart', '.packages', 'org-dartlang-app', <String>['/example', '/gen']);
|
final PackageUriMapper packageUriMapper = PackageUriMapper('/example/lib/main.dart', '.packages', 'org-dartlang-app', <String>['/example/lib/', '/gen/lib/']);
|
||||||
expect(packageUriMapper.map('/example/lib/main.dart').toString(), 'package:example/main.dart');
|
expect(packageUriMapper.map('/example/lib/main.dart').toString(), 'package:example/main.dart');
|
||||||
}, overrides: <Type, Generator>{
|
}, overrides: <Type, Generator>{
|
||||||
FileSystem: () => mockFileSystem,
|
FileSystem: () => mockFileSystem,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user