Stop reading .packages from flutter_tools. (#154912)
This commit is contained in:
parent
15c0ae0e5a
commit
2812d4685c
@ -215,8 +215,9 @@ class Cache {
|
||||
/// 1. FLUTTER_ROOT environment variable contains the path.
|
||||
/// 2. Platform script is a data URI scheme, returning `../..` to support
|
||||
/// tests run from `packages/flutter_tools`.
|
||||
/// 3. Platform script is package URI scheme, returning the grandparent directory
|
||||
/// of the package config file location from `packages/flutter_tools/.packages`.
|
||||
/// 3. Platform script is package URI scheme, returning the grandgrandparent
|
||||
/// directory of the package config file location from
|
||||
/// `packages/flutter_tools/.dart_tool/package_config.json`.
|
||||
/// 4. Platform script file path is the snapshot path generated by `bin/flutter`,
|
||||
/// returning the grandparent directory from `bin/cache`.
|
||||
/// 5. Platform script file name is the entrypoint in `packages/flutter_tools/bin/flutter_tools.dart`,
|
||||
@ -246,7 +247,7 @@ class Cache {
|
||||
final String packageConfigPath = Uri.parse(platform.packageConfig!).toFilePath(
|
||||
windows: platform.isWindows,
|
||||
);
|
||||
return normalize(dirname(dirname(dirname(packageConfigPath))));
|
||||
return normalize(dirname(dirname(dirname(dirname(packageConfigPath)))));
|
||||
}
|
||||
|
||||
if (platform.script.scheme == 'file') {
|
||||
|
@ -33,12 +33,6 @@ File? findPackageConfigFile(Directory dir) {
|
||||
if (candidatePackageConfigFile.existsSync()) {
|
||||
return candidatePackageConfigFile;
|
||||
}
|
||||
// TODO(sigurdm): we should not need to check this file, it is obsolete,
|
||||
// https://github.com/flutter/flutter/issues/150908.
|
||||
final File candidatePackagesFile = candidateDir.childFile('.packages');
|
||||
if (candidatePackagesFile.existsSync()) {
|
||||
return candidatePackagesFile;
|
||||
}
|
||||
final Directory parentDir = candidateDir.parent;
|
||||
if (fileSystem.identicalSync(parentDir.path, candidateDir.path)) {
|
||||
return null;
|
||||
|
@ -98,7 +98,7 @@ void main() {
|
||||
// Sets up the minimal mock project files necessary to look like a Flutter project.
|
||||
void createCoreMockProjectFiles() {
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').createSync();
|
||||
fileSystem.directory('.dart_tool').childFile('package_config.json').createSync(recursive: true);
|
||||
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||
}
|
||||
|
||||
@ -264,7 +264,7 @@ void main() {
|
||||
osUtils: FakeOperatingSystemUtils(),
|
||||
);
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').createSync();
|
||||
fileSystem.directory('.dart_tool').childFile('package_config.json').createSync(recursive: true);
|
||||
fileSystem.file(fileSystem.path.join('lib', 'main.dart'))
|
||||
.createSync(recursive: true);
|
||||
|
||||
|
@ -108,7 +108,7 @@ void main() {
|
||||
// Sets up the minimal mock project files necessary to look like a Flutter project.
|
||||
void createCoreMockProjectFiles() {
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').createSync();
|
||||
fileSystem.directory('.dart_tool').childFile('package_config.json').createSync(recursive: true);
|
||||
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||
}
|
||||
|
||||
@ -277,7 +277,7 @@ void main() {
|
||||
osUtils: FakeOperatingSystemUtils(),
|
||||
);
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').createSync();
|
||||
fileSystem.directory('.dart_tool').childFile('package_config.json').createSync(recursive: true);
|
||||
fileSystem.file(fileSystem.path.join('lib', 'main.dart'))
|
||||
.createSync(recursive: true);
|
||||
|
||||
|
@ -74,7 +74,7 @@ void main() {
|
||||
// Creates the mock files necessary to look like a Flutter project.
|
||||
void setUpMockCoreProjectFiles() {
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').createSync();
|
||||
fileSystem.directory('.dart_tool').childFile('package_config.json').createSync(recursive: true);
|
||||
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||
}
|
||||
|
||||
@ -664,7 +664,7 @@ project(runner LANGUAGES CXX)
|
||||
set(BINARY_NAME "fizz_bar")
|
||||
''');
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').createSync();
|
||||
fileSystem.directory('.dart_tool').childFile('package_config.json').createSync(recursive: true);
|
||||
final FlutterProject flutterProject = FlutterProject.fromDirectoryTest(fileSystem.currentDirectory);
|
||||
|
||||
expect(getCmakeExecutableName(flutterProject.linux), 'fizz_bar');
|
||||
|
@ -47,7 +47,7 @@ void main() {
|
||||
fileSystem.file('pubspec.yaml')
|
||||
..createSync()
|
||||
..writeAsStringSync('name: foo\n');
|
||||
fileSystem.file('.packages').createSync();
|
||||
fileSystem.directory('.dart_tool').childFile('package_config.json').createSync(recursive: true);
|
||||
fileSystem.file(fileSystem.path.join('web', 'index.html')).createSync(recursive: true);
|
||||
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||
artifacts = Artifacts.test(fileSystem: fileSystem);
|
||||
@ -430,10 +430,28 @@ void setupFileSystemForEndToEndTest(FileSystem fileSystem) {
|
||||
}
|
||||
|
||||
// Project files.
|
||||
fileSystem.file('.packages')
|
||||
.writeAsStringSync('''
|
||||
foo:lib/
|
||||
fizz:bar/lib/
|
||||
fileSystem
|
||||
.directory('.dart_tool')
|
||||
.childFile('package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
{
|
||||
"packages": [
|
||||
{
|
||||
"name": "foo",
|
||||
"rootUri": "../",
|
||||
"packageUri": "lib/",
|
||||
"languageVersion": "3.2"
|
||||
},
|
||||
{
|
||||
"name": "fizz",
|
||||
"rootUri": "../bar",
|
||||
"packageUri": "lib/",
|
||||
"languageVersion": "3.2"
|
||||
}
|
||||
],
|
||||
"configVersion": 2
|
||||
}
|
||||
''');
|
||||
fileSystem.file('pubspec.yaml')
|
||||
.writeAsStringSync('''
|
||||
|
@ -65,7 +65,7 @@ void main() {
|
||||
// Creates the mock files necessary to look like a Flutter project.
|
||||
void setUpMockCoreProjectFiles() {
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').createSync();
|
||||
fileSystem.directory('.dart_tool').childFile('package_config.json').createSync(recursive: true);
|
||||
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,13 @@ void main() {
|
||||
|
||||
expect(projectUnderTest.flutterPluginsFile, isNot(exists));
|
||||
expect(projectUnderTest.flutterPluginsDependenciesFile, isNot(exists));
|
||||
expect(projectUnderTest.directory.childFile('.packages'), isNot(exists));
|
||||
expect(
|
||||
projectUnderTest
|
||||
.directory
|
||||
.childDirectory('.dart_tool')
|
||||
.childFile('package_config.json'),
|
||||
isNot(exists),
|
||||
);
|
||||
|
||||
expect(xcodeProjectInterpreter.workspaces, const <CleanWorkspaceCall>[
|
||||
CleanWorkspaceCall('/ios/Runner.xcworkspace', 'Runner', false),
|
||||
@ -231,7 +237,7 @@ FlutterProject setupProjectUnderTest(Directory currentDirectory, bool setupXcode
|
||||
projectUnderTest.macos.hostAppRoot.childDirectory('Runner.xcworkspace').createSync(recursive: true);
|
||||
}
|
||||
projectUnderTest.dartTool.createSync(recursive: true);
|
||||
projectUnderTest.directory.childFile('.packages').createSync(recursive: true);
|
||||
projectUnderTest.directory.childDirectory('.dart_tool').childFile('package_config.jon').createSync(recursive: true);
|
||||
projectUnderTest.android.ephemeralDirectory.createSync(recursive: true);
|
||||
|
||||
projectUnderTest.ios.ephemeralDirectory.createSync(recursive: true);
|
||||
|
@ -40,7 +40,7 @@ class FakePub extends Fake implements Pub {
|
||||
bool shouldSkipThirdPartyGenerator = true,
|
||||
PubOutputMode outputMode = PubOutputMode.all,
|
||||
}) async {
|
||||
project.directory.childFile('.packages').createSync();
|
||||
project.directory.childDirectory('.dart_tool').childFile('package_config.json').createSync(recursive: true);
|
||||
if (offline) {
|
||||
calledGetOffline += 1;
|
||||
} else {
|
||||
|
@ -83,7 +83,6 @@ void main() {
|
||||
fileSystem.currentDirectory.childFile('pubspec.yaml').createSync();
|
||||
fileSystem.currentDirectory.childFile('.flutter-plugins').createSync();
|
||||
fileSystem.currentDirectory.childFile('.flutter-plugins-dependencies').createSync();
|
||||
fileSystem.currentDirectory.childFile('.packages').writeAsBytesSync(<int>[0]);
|
||||
fileSystem.currentDirectory.childFile('.dart_tool/package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsBytesSync(<int>[0]);
|
||||
|
@ -122,7 +122,6 @@ void main() {
|
||||
testUsingContext('bundle fails to build for Windows if feature is disabled', () async {
|
||||
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||
globals.fs.file('pubspec.yaml').createSync(recursive: true);
|
||||
globals.fs.file('.packages').createSync(recursive: true);
|
||||
final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand(
|
||||
logger: BufferLogger.test(),
|
||||
));
|
||||
@ -142,7 +141,6 @@ void main() {
|
||||
testUsingContext('bundle fails to build for Linux if feature is disabled', () async {
|
||||
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||
globals.fs.file('pubspec.yaml').createSync();
|
||||
globals.fs.file('.packages').createSync();
|
||||
final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand(
|
||||
logger: BufferLogger.test(),
|
||||
));
|
||||
@ -162,7 +160,6 @@ void main() {
|
||||
testUsingContext('bundle fails to build for macOS if feature is disabled', () async {
|
||||
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||
globals.fs.file('pubspec.yaml').createSync();
|
||||
globals.fs.file('.packages').createSync();
|
||||
final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand(
|
||||
logger: BufferLogger.test(),
|
||||
));
|
||||
@ -182,7 +179,6 @@ void main() {
|
||||
testUsingContext('bundle --tree-shake-icons fails', () async {
|
||||
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||
globals.fs.file('pubspec.yaml').createSync();
|
||||
globals.fs.file('.packages').createSync();
|
||||
final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand(
|
||||
logger: BufferLogger.test(),
|
||||
));
|
||||
@ -201,7 +197,6 @@ void main() {
|
||||
testUsingContext('bundle can build for Windows if feature is enabled', () async {
|
||||
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||
globals.fs.file('pubspec.yaml').createSync();
|
||||
globals.fs.file('.packages').createSync();
|
||||
final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand(
|
||||
logger: BufferLogger.test(),
|
||||
));
|
||||
@ -221,7 +216,6 @@ void main() {
|
||||
testUsingContext('bundle can build for Linux if feature is enabled', () async {
|
||||
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||
globals.fs.file('pubspec.yaml').createSync();
|
||||
globals.fs.file('.packages').createSync();
|
||||
final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand(
|
||||
logger: BufferLogger.test(),
|
||||
));
|
||||
@ -241,7 +235,6 @@ void main() {
|
||||
testUsingContext('bundle can build for macOS if feature is enabled', () async {
|
||||
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||
globals.fs.file('pubspec.yaml').createSync();
|
||||
globals.fs.file('.packages').createSync();
|
||||
final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand(
|
||||
logger: BufferLogger.test(),
|
||||
));
|
||||
@ -261,7 +254,7 @@ void main() {
|
||||
testUsingContext('passes track widget creation through', () async {
|
||||
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||
globals.fs.file('pubspec.yaml').createSync();
|
||||
globals.fs.file('.packages').createSync();
|
||||
|
||||
final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand(
|
||||
logger: BufferLogger.test(),
|
||||
));
|
||||
@ -294,7 +287,6 @@ void main() {
|
||||
testUsingContext('passes dart-define through', () async {
|
||||
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||
globals.fs.file('pubspec.yaml').createSync();
|
||||
globals.fs.file('.packages').createSync();
|
||||
final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand(
|
||||
logger: BufferLogger.test(),
|
||||
));
|
||||
@ -328,7 +320,6 @@ void main() {
|
||||
testUsingContext('passes filesystem-scheme through', () async {
|
||||
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||
globals.fs.file('pubspec.yaml').createSync();
|
||||
globals.fs.file('.packages').createSync();
|
||||
final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand(
|
||||
logger: BufferLogger.test(),
|
||||
));
|
||||
@ -361,7 +352,6 @@ void main() {
|
||||
testUsingContext('passes filesystem-roots through', () async {
|
||||
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||
globals.fs.file('pubspec.yaml').createSync();
|
||||
globals.fs.file('.packages').createSync();
|
||||
final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand(
|
||||
logger: BufferLogger.test(),
|
||||
));
|
||||
@ -395,7 +385,6 @@ void main() {
|
||||
testUsingContext('passes extra frontend-options through', () async {
|
||||
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||
globals.fs.file('pubspec.yaml').createSync();
|
||||
globals.fs.file('.packages').createSync();
|
||||
final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand(
|
||||
logger: BufferLogger.test(),
|
||||
));
|
||||
@ -429,7 +418,6 @@ void main() {
|
||||
testUsingContext('passes extra gen_snapshot-options through', () async {
|
||||
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||
globals.fs.file('pubspec.yaml').createSync();
|
||||
globals.fs.file('.packages').createSync();
|
||||
final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand(
|
||||
logger: BufferLogger.test(),
|
||||
));
|
||||
@ -463,7 +451,6 @@ void main() {
|
||||
testUsingContext('passes profile options through', () async {
|
||||
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||
globals.fs.file('pubspec.yaml').createSync();
|
||||
globals.fs.file('.packages').createSync();
|
||||
final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand(
|
||||
logger: BufferLogger.test(),
|
||||
));
|
||||
@ -505,7 +492,6 @@ void main() {
|
||||
testUsingContext('passes release options through', () async {
|
||||
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||
globals.fs.file('pubspec.yaml').createSync();
|
||||
globals.fs.file('.packages').createSync();
|
||||
final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand(
|
||||
logger: BufferLogger.test(),
|
||||
));
|
||||
|
@ -189,7 +189,6 @@ name: example
|
||||
flutter:
|
||||
module: {}
|
||||
''');
|
||||
fileSystem.file('.packages').createSync();
|
||||
final FlutterProject flutterProject = FlutterProjectFactory(
|
||||
fileSystem: fileSystem,
|
||||
logger: BufferLogger.test(),
|
||||
@ -202,7 +201,6 @@ flutter:
|
||||
testWithoutContext('isSupportedForProject is true with editable host app', () async {
|
||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').createSync();
|
||||
fileSystem.directory('android').createSync();
|
||||
final FlutterProject flutterProject = FlutterProjectFactory(
|
||||
fileSystem: fileSystem,
|
||||
@ -217,7 +215,6 @@ flutter:
|
||||
testWithoutContext('isSupportedForProject is false with no host app and no module', () async {
|
||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').createSync();
|
||||
final FlutterProject flutterProject = FlutterProjectFactory(
|
||||
fileSystem: fileSystem,
|
||||
logger: BufferLogger.test(),
|
||||
|
@ -424,7 +424,6 @@ void main() {
|
||||
|
||||
testUsingContext('returns null when there is no ios or .ios directory', () async {
|
||||
globals.fs.file('pubspec.yaml').createSync();
|
||||
globals.fs.file('.packages').createSync();
|
||||
final BuildableIOSApp? iosApp = await IOSApp.fromIosProject(
|
||||
FlutterProject.fromDirectory(globals.fs.currentDirectory).ios, null) as BuildableIOSApp?;
|
||||
|
||||
@ -433,7 +432,6 @@ void main() {
|
||||
|
||||
testUsingContext('returns null when there is no Runner.xcodeproj', () async {
|
||||
globals.fs.file('pubspec.yaml').createSync();
|
||||
globals.fs.file('.packages').createSync();
|
||||
globals.fs.file('ios/FooBar.xcodeproj').createSync(recursive: true);
|
||||
final BuildableIOSApp? iosApp = await IOSApp.fromIosProject(
|
||||
FlutterProject.fromDirectory(globals.fs.currentDirectory).ios, null) as BuildableIOSApp?;
|
||||
@ -443,7 +441,6 @@ void main() {
|
||||
|
||||
testUsingContext('returns null when there is no Runner.xcodeproj/project.pbxproj', () async {
|
||||
globals.fs.file('pubspec.yaml').createSync();
|
||||
globals.fs.file('.packages').createSync();
|
||||
globals.fs.file('ios/Runner.xcodeproj').createSync(recursive: true);
|
||||
final BuildableIOSApp? iosApp = await IOSApp.fromIosProject(
|
||||
FlutterProject.fromDirectory(globals.fs.currentDirectory).ios, null) as BuildableIOSApp?;
|
||||
@ -453,7 +450,6 @@ void main() {
|
||||
|
||||
testUsingContext('returns null when there with no product identifier', () async {
|
||||
globals.fs.file('pubspec.yaml').createSync();
|
||||
globals.fs.file('.packages').createSync();
|
||||
final Directory project = globals.fs.directory('ios/Runner.xcodeproj')..createSync(recursive: true);
|
||||
project.childFile('project.pbxproj').createSync();
|
||||
final BuildableIOSApp? iosApp = await IOSApp.fromIosProject(
|
||||
|
@ -32,7 +32,7 @@ void main() {
|
||||
);
|
||||
|
||||
await bundle.build(
|
||||
packageConfigPath: '.packages',
|
||||
packageConfigPath: '.dart_tool/package_config.json',
|
||||
flutterProject: FlutterProject.fromDirectoryTest(fileSystem.currentDirectory),
|
||||
flavor: flavor,
|
||||
);
|
||||
@ -45,7 +45,7 @@ void main() {
|
||||
final BufferLogger logger = BufferLogger.test();
|
||||
final FakePlatform platform = FakePlatform();
|
||||
|
||||
fileSystem.file('.packages').createSync();
|
||||
fileSystem.directory('.dart_tool').childFile('package_config.json').createSync(recursive: true);
|
||||
fileSystem.file(fileSystem.path.join('assets', 'common', 'image.png')).createSync(recursive: true);
|
||||
fileSystem.file(fileSystem.path.join('assets', 'vanilla', 'ice-cream.png')).createSync(recursive: true);
|
||||
fileSystem.file(fileSystem.path.join('assets', 'strawberry', 'ice-cream.png')).createSync(recursive: true);
|
||||
@ -108,7 +108,7 @@ flutter:
|
||||
fileSystem.currentDirectory = fileSystem.systemTempDirectory.createTempSync('flutter_asset_bundle_test.');
|
||||
final BufferLogger logger = BufferLogger.test();
|
||||
final FakePlatform platform = FakePlatform();
|
||||
fileSystem.file('.packages').createSync();
|
||||
fileSystem.directory('.dart_tool').childFile('package_config.json').createSync(recursive: true);
|
||||
fileSystem.file(fileSystem.path.join('assets', 'unflavored.png')).createSync(recursive: true);
|
||||
fileSystem.file(fileSystem.path.join('assets', 'vanillaOrange.png')).createSync(recursive: true);
|
||||
|
||||
@ -145,7 +145,7 @@ flutter:
|
||||
fileSystem.currentDirectory = fileSystem.systemTempDirectory.createTempSync('flutter_asset_bundle_test.');
|
||||
final BufferLogger logger = BufferLogger.test();
|
||||
final FakePlatform platform = FakePlatform();
|
||||
fileSystem.file('.packages').createSync();
|
||||
fileSystem.directory('.dart_tool').childFile('package_config.json').createSync(recursive: true);
|
||||
fileSystem.file(fileSystem.path.join('vanilla', 'vanilla.png')).createSync(recursive: true);
|
||||
fileSystem.file(fileSystem.path.join('vanilla', 'flavorless.png')).createSync(recursive: true);
|
||||
|
||||
@ -180,7 +180,7 @@ flutter:
|
||||
fileSystem.currentDirectory = fileSystem.systemTempDirectory.createTempSync('flutter_asset_bundle_test.');
|
||||
final BufferLogger logger = BufferLogger.test();
|
||||
final FakePlatform platform = FakePlatform();
|
||||
fileSystem.file('.packages').createSync();
|
||||
fileSystem.directory('.dart_tool').childFile('package_config.json').createSync(recursive: true);
|
||||
fileSystem.file('orange.png').createSync(recursive: true);
|
||||
fileSystem.file('pubspec.yaml')
|
||||
..createSync()
|
||||
@ -215,7 +215,7 @@ flutter:
|
||||
fileSystem.currentDirectory = fileSystem.systemTempDirectory.createTempSync('flutter_asset_bundle_test.');
|
||||
final BufferLogger logger = BufferLogger.test();
|
||||
final FakePlatform platform = FakePlatform();
|
||||
fileSystem.file('.packages').createSync();
|
||||
fileSystem.directory('.dart_tool').childFile('package_config.json').createSync(recursive: true);
|
||||
fileSystem.file(fileSystem.path.join('vanilla', 'actually-strawberry.png')).createSync(recursive: true);
|
||||
fileSystem.file(fileSystem.path.join('vanilla', 'vanilla.png')).createSync(recursive: true);
|
||||
|
||||
|
@ -46,10 +46,25 @@ $fontsSection
|
||||
''');
|
||||
}
|
||||
|
||||
void writePackagesFile(String packages) {
|
||||
globals.fs.file('.packages')
|
||||
..createSync()
|
||||
..writeAsStringSync(packages);
|
||||
void writePackageConfigFile(Map<String, String> packages) {
|
||||
globals.fs.directory('.dart_tool').childFile('package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync(
|
||||
json.encode(<String, dynamic>{
|
||||
'packages': <dynamic>[
|
||||
...packages.entries.map((MapEntry<String, String> entry) {
|
||||
return <String, dynamic>{
|
||||
'name': entry.key,
|
||||
'rootUri': '../${entry.value}',
|
||||
'packageUri': 'lib/',
|
||||
'languageVersion': '3.2',
|
||||
};
|
||||
}),
|
||||
],
|
||||
'configVersion': 2,
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> buildAndVerifyFonts(
|
||||
@ -59,7 +74,7 @@ $fontsSection
|
||||
String expectedAssetManifest,
|
||||
) async {
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
await bundle.build(packageConfigPath: '.packages');
|
||||
await bundle.build(packageConfigPath: '.dart_tool/package_config.json');
|
||||
|
||||
for (final String packageName in packages) {
|
||||
for (final String packageFont in packageFonts) {
|
||||
@ -106,11 +121,11 @@ $fontsSection
|
||||
|
||||
testUsingContext('App includes neither font manifest nor fonts when no defines fonts', () async {
|
||||
writePubspecFile('pubspec.yaml', 'test');
|
||||
writePackagesFile('test_package:p/p/lib/');
|
||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
||||
writePubspecFile('p/p/pubspec.yaml', 'test_package');
|
||||
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
await bundle.build(packageConfigPath: '.packages');
|
||||
await bundle.build(packageConfigPath: '.dart_tool/package_config.json');
|
||||
expect(bundle.entries.keys, unorderedEquals(<String>['AssetManifest.bin',
|
||||
'AssetManifest.json', 'FontManifest.json', 'NOTICES.Z']));
|
||||
}, overrides: <Type, Generator>{
|
||||
@ -125,7 +140,7 @@ $fontsSection
|
||||
- asset: packages/test_package/bar
|
||||
''';
|
||||
writePubspecFile('pubspec.yaml', 'test', fontsSection: fontsSection);
|
||||
writePackagesFile('test_package:p/p/lib/');
|
||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
||||
writePubspecFile('p/p/pubspec.yaml', 'test_package');
|
||||
|
||||
const String font = 'bar';
|
||||
@ -152,7 +167,7 @@ $fontsSection
|
||||
- asset: a/bar
|
||||
''';
|
||||
writePubspecFile('pubspec.yaml', 'test', fontsSection: fontsSection);
|
||||
writePackagesFile('test_package:p/p/lib/');
|
||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
||||
writePubspecFile('p/p/pubspec.yaml', 'test_package');
|
||||
|
||||
const String packageFont = 'bar';
|
||||
@ -176,7 +191,7 @@ $fontsSection
|
||||
|
||||
testUsingContext('App uses package font with own font file', () async {
|
||||
writePubspecFile('pubspec.yaml', 'test');
|
||||
writePackagesFile('test_package:p/p/lib/');
|
||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
||||
const String fontsSection = '''
|
||||
- family: foo
|
||||
fonts:
|
||||
@ -207,7 +222,12 @@ $fontsSection
|
||||
|
||||
testUsingContext('App uses package font with font file from another package', () async {
|
||||
writePubspecFile('pubspec.yaml', 'test');
|
||||
writePackagesFile('test_package:p/p/lib/\ntest_package2:p2/p/lib/');
|
||||
writePackageConfigFile(
|
||||
<String, String>{
|
||||
'test_package': 'p/p/',
|
||||
'test_package2': 'p2/p/',
|
||||
},
|
||||
);
|
||||
const String fontsSection = '''
|
||||
- family: foo
|
||||
fonts:
|
||||
@ -239,7 +259,7 @@ $fontsSection
|
||||
|
||||
testUsingContext('App uses package font with properties and own font file', () async {
|
||||
writePubspecFile('pubspec.yaml', 'test');
|
||||
writePackagesFile('test_package:p/p/lib/');
|
||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
||||
|
||||
const String pubspec = '''
|
||||
- family: foo
|
||||
@ -281,7 +301,7 @@ $fontsSection
|
||||
'test',
|
||||
fontsSection: fontsSection,
|
||||
);
|
||||
writePackagesFile('test_package:p/p/lib/');
|
||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
||||
writePubspecFile(
|
||||
'p/p/pubspec.yaml',
|
||||
'test_package',
|
||||
|
@ -57,10 +57,25 @@ $assetsSection
|
||||
''');
|
||||
}
|
||||
|
||||
void writePackagesFile(String packages) {
|
||||
globals.fs.file('.packages')
|
||||
..createSync()
|
||||
..writeAsStringSync(packages);
|
||||
void writePackageConfigFile(Map<String, String> packages) {
|
||||
globals.fs.directory('.dart_tool').childFile('package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync(
|
||||
json.encode(<String, dynamic>{
|
||||
'packages': <dynamic>[
|
||||
...packages.entries.map((MapEntry<String, String> entry) {
|
||||
return <String, dynamic>{
|
||||
'name': entry.key,
|
||||
'rootUri': '../${entry.value}',
|
||||
'packageUri': 'lib/',
|
||||
'languageVersion': '3.2',
|
||||
};
|
||||
}),
|
||||
],
|
||||
'configVersion': 2,
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Map<Object, Object> assetManifestBinToJson(Map<Object, Object> manifest) {
|
||||
@ -78,7 +93,7 @@ $assetsSection
|
||||
) async {
|
||||
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
await bundle.build(packageConfigPath: '.packages');
|
||||
await bundle.build(packageConfigPath: '.dart_tool/package_config.json');
|
||||
|
||||
for (final String packageName in packages) {
|
||||
for (final String asset in assets) {
|
||||
@ -134,11 +149,11 @@ $assetsSection
|
||||
group('AssetBundle assets from packages', () {
|
||||
testUsingContext('No assets are bundled when the package has no assets', () async {
|
||||
writePubspecFile('pubspec.yaml', 'test');
|
||||
writePackagesFile('test_package:p/p/lib/');
|
||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
||||
writePubspecFile('p/p/pubspec.yaml', 'test_package');
|
||||
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
await bundle.build(packageConfigPath: '.packages');
|
||||
await bundle.build(packageConfigPath: '.dart_tool/package_config.json');
|
||||
expect(bundle.entries.keys, unorderedEquals(
|
||||
<String>['NOTICES.Z', 'AssetManifest.json', 'AssetManifest.bin', 'FontManifest.json']));
|
||||
const String expectedAssetManifest = '{}';
|
||||
@ -157,14 +172,14 @@ $assetsSection
|
||||
|
||||
testUsingContext('No assets are bundled when the package has an asset that is not listed', () async {
|
||||
writePubspecFile('pubspec.yaml', 'test');
|
||||
writePackagesFile('test_package:p/p/lib/');
|
||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
||||
writePubspecFile('p/p/pubspec.yaml', 'test_package');
|
||||
|
||||
final List<String> assets = <String>['a/foo'];
|
||||
writeAssets('p/p/', assets);
|
||||
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
await bundle.build(packageConfigPath: '.packages');
|
||||
await bundle.build(packageConfigPath: '.dart_tool/package_config.json');
|
||||
expect(bundle.entries.keys, unorderedEquals(
|
||||
<String>['NOTICES.Z', 'AssetManifest.json', 'AssetManifest.bin', 'FontManifest.json']));
|
||||
const String expectedAssetManifest = '{}';
|
||||
@ -184,7 +199,7 @@ $assetsSection
|
||||
testUsingContext('One asset is bundled when the package has and lists one '
|
||||
'asset its pubspec', () async {
|
||||
writePubspecFile('pubspec.yaml', 'test');
|
||||
writePackagesFile('test_package:p/p/lib/');
|
||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
||||
|
||||
final List<String> assets = <String>['a/foo'];
|
||||
writePubspecFile(
|
||||
@ -221,7 +236,7 @@ $assetsSection
|
||||
'test',
|
||||
assets: assetEntries,
|
||||
);
|
||||
writePackagesFile('test_package:p/p/lib/');
|
||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
||||
writePubspecFile('p/p/pubspec.yaml', 'test_package');
|
||||
|
||||
final List<String> assets = <String>['a/foo'];
|
||||
@ -246,7 +261,7 @@ $assetsSection
|
||||
testUsingContext('One asset and its variant are bundled when the package '
|
||||
'has an asset and a variant, and lists the asset in its pubspec', () async {
|
||||
writePubspecFile('pubspec.yaml', 'test');
|
||||
writePackagesFile('test_package:p/p/lib/');
|
||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
||||
writePubspecFile(
|
||||
'p/p/pubspec.yaml',
|
||||
'test_package',
|
||||
@ -283,7 +298,7 @@ $assetsSection
|
||||
'test',
|
||||
assets: <String>['packages/test_package/a/foo'],
|
||||
);
|
||||
writePackagesFile('test_package:p/p/lib/');
|
||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
||||
writePubspecFile(
|
||||
'p/p/pubspec.yaml',
|
||||
'test_package',
|
||||
@ -312,7 +327,7 @@ $assetsSection
|
||||
testUsingContext('Two assets are bundled when the package has and lists '
|
||||
'two assets in its pubspec', () async {
|
||||
writePubspecFile('pubspec.yaml', 'test');
|
||||
writePackagesFile('test_package:p/p/lib/');
|
||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
||||
|
||||
final List<String> assets = <String>['a/foo', 'a/bar'];
|
||||
writePubspecFile(
|
||||
@ -351,7 +366,7 @@ $assetsSection
|
||||
'test',
|
||||
assets: assetEntries,
|
||||
);
|
||||
writePackagesFile('test_package:p/p/lib/');
|
||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
||||
|
||||
final List<String> assets = <String>['a/foo', 'a/bar'];
|
||||
writePubspecFile(
|
||||
@ -384,7 +399,12 @@ $assetsSection
|
||||
'pubspec.yaml',
|
||||
'test',
|
||||
);
|
||||
writePackagesFile('test_package:p/p/lib/\ntest_package2:p2/p/lib/');
|
||||
writePackageConfigFile(
|
||||
<String, String>{
|
||||
'test_package': 'p/p/',
|
||||
'test_package2': 'p2/p/',
|
||||
},
|
||||
);
|
||||
writePubspecFile(
|
||||
'p/p/pubspec.yaml',
|
||||
'test_package',
|
||||
@ -431,7 +451,12 @@ $assetsSection
|
||||
'test',
|
||||
assets: assetEntries,
|
||||
);
|
||||
writePackagesFile('test_package:p/p/lib/\ntest_package2:p2/p/lib/');
|
||||
writePackageConfigFile(
|
||||
<String, String>{
|
||||
'test_package': 'p/p/',
|
||||
'test_package2': 'p2/p/',
|
||||
},
|
||||
);
|
||||
writePubspecFile(
|
||||
'p/p/pubspec.yaml',
|
||||
'test_package',
|
||||
@ -472,7 +497,12 @@ $assetsSection
|
||||
'pubspec.yaml',
|
||||
'test',
|
||||
);
|
||||
writePackagesFile('test_package:p/p/lib/\ntest_package2:p2/p/lib/');
|
||||
writePackageConfigFile(
|
||||
<String, String>{
|
||||
'test_package': 'p/p/',
|
||||
'test_package2': 'p2/p/',
|
||||
},
|
||||
);
|
||||
writePubspecFile(
|
||||
'p/p/pubspec.yaml',
|
||||
'test_package',
|
||||
@ -506,7 +536,7 @@ $assetsSection
|
||||
|
||||
testUsingContext('Asset paths can contain URL reserved characters', () async {
|
||||
writePubspecFile('pubspec.yaml', 'test');
|
||||
writePackagesFile('test_package:p/p/lib/');
|
||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
||||
|
||||
final List<String> assets = <String>['a/foo', 'a/foo [x]'];
|
||||
writePubspecFile(
|
||||
@ -538,7 +568,7 @@ $assetsSection
|
||||
group('AssetBundle assets from scanned paths', () {
|
||||
testUsingContext('Two assets are bundled when scanning their directory', () async {
|
||||
writePubspecFile('pubspec.yaml', 'test');
|
||||
writePackagesFile('test_package:p/p/lib/');
|
||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
||||
|
||||
final List<String> assetsOnDisk = <String>['a/foo', 'a/bar'];
|
||||
final List<String> assetsOnManifest = <String>['a/'];
|
||||
@ -571,7 +601,7 @@ $assetsSection
|
||||
|
||||
testUsingContext('Two assets are bundled when listing one and scanning second directory', () async {
|
||||
writePubspecFile('pubspec.yaml', 'test');
|
||||
writePackagesFile('test_package:p/p/lib/');
|
||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
||||
|
||||
final List<String> assetsOnDisk = <String>['a/foo', 'abc/bar'];
|
||||
final List<String> assetOnManifest = <String>['a/foo', 'abc/'];
|
||||
@ -604,7 +634,7 @@ $assetsSection
|
||||
|
||||
testUsingContext('One asset is bundled with variant, scanning wrong directory', () async {
|
||||
writePubspecFile('pubspec.yaml', 'test');
|
||||
writePackagesFile('test_package:p/p/lib/');
|
||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
||||
|
||||
final List<String> assetsOnDisk = <String>['a/foo','a/b/foo','a/bar'];
|
||||
final List<String> assetOnManifest = <String>['a','a/bar']; // can't list 'a' as asset, should be 'a/'
|
||||
@ -618,7 +648,7 @@ $assetsSection
|
||||
writeAssets('p/p/', assetsOnDisk);
|
||||
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
await bundle.build(packageConfigPath: '.packages');
|
||||
await bundle.build(packageConfigPath: '.dart_tool/package_config.json');
|
||||
|
||||
expect(bundle.entries['AssetManifest.json'], isNull,
|
||||
reason: 'Invalid pubspec.yaml should not generate AssetManifest.json' );
|
||||
@ -631,7 +661,7 @@ $assetsSection
|
||||
group('AssetBundle assets from scanned paths with MemoryFileSystem', () {
|
||||
testUsingContext('One asset is bundled with variant, scanning directory', () async {
|
||||
writePubspecFile('pubspec.yaml', 'test');
|
||||
writePackagesFile('test_package:p/p/lib/');
|
||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
||||
|
||||
final List<String> assetsOnDisk = <String>['a/foo','a/2x/foo'];
|
||||
final List<String> assetOnManifest = <String>['a/',];
|
||||
@ -661,7 +691,7 @@ $assetsSection
|
||||
|
||||
testUsingContext('No asset is bundled with variant, no assets or directories are listed', () async {
|
||||
writePubspecFile('pubspec.yaml', 'test');
|
||||
writePackagesFile('test_package:p/p/lib/');
|
||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
||||
|
||||
final List<String> assetsOnDisk = <String>['a/foo', 'a/2x/foo'];
|
||||
final List<String> assetOnManifest = <String>[];
|
||||
@ -687,7 +717,7 @@ $assetsSection
|
||||
|
||||
testUsingContext('Expect error generating manifest, wrong non-existing directory is listed', () async {
|
||||
writePubspecFile('pubspec.yaml', 'test');
|
||||
writePackagesFile('test_package:p/p/lib/');
|
||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
||||
|
||||
final List<String> assetOnManifest = <String>['c/'];
|
||||
|
||||
@ -698,7 +728,7 @@ $assetsSection
|
||||
);
|
||||
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
await bundle.build(packageConfigPath: '.packages');
|
||||
await bundle.build(packageConfigPath: '.dart_tool/package_config.json');
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => testFileSystem,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
|
@ -27,6 +27,31 @@ import '../src/context.dart';
|
||||
void main() {
|
||||
const String shaderLibDir = '/./shader_lib';
|
||||
|
||||
File createPackageConfig(
|
||||
FileSystem fileSystem, {
|
||||
Map<String, String> packages = const <String, String>{},
|
||||
}
|
||||
) {
|
||||
final File file = fileSystem.directory('.dart_tool').childFile('package_config.json');
|
||||
file.createSync(recursive: true);
|
||||
file.writeAsStringSync(
|
||||
json.encode(<String, dynamic>{
|
||||
'packages': <dynamic>[
|
||||
...packages.entries.map((MapEntry<String, String> entry) {
|
||||
return <String, dynamic>{
|
||||
'name': entry.key,
|
||||
'rootUri': '../${entry.value}',
|
||||
'packageUri': 'lib/',
|
||||
'languageVersion': '3.2',
|
||||
};
|
||||
}),
|
||||
],
|
||||
'configVersion': 2,
|
||||
},
|
||||
),
|
||||
);
|
||||
return file;
|
||||
}
|
||||
group('AssetBundle.build (using context)', () {
|
||||
late FileSystem testFileSystem;
|
||||
late Platform platform;
|
||||
@ -39,7 +64,7 @@ void main() {
|
||||
|
||||
testUsingContext('nonempty', () async {
|
||||
final AssetBundle ab = AssetBundleFactory.instance.createBundle();
|
||||
expect(await ab.build(packageConfigPath: '.packages'), 0);
|
||||
expect(await ab.build(packageConfigPath: '.dart_tool/package_config.json'), 0);
|
||||
expect(ab.entries.length, greaterThan(0));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => testFileSystem,
|
||||
@ -53,7 +78,7 @@ void main() {
|
||||
..writeAsStringSync('');
|
||||
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
await bundle.build(packageConfigPath: '.packages');
|
||||
await bundle.build(packageConfigPath: '.dart_tool/package_config.json');
|
||||
expect(bundle.entries.keys,
|
||||
unorderedEquals(<String>['AssetManifest.json', 'AssetManifest.bin'])
|
||||
);
|
||||
@ -75,7 +100,7 @@ void main() {
|
||||
});
|
||||
|
||||
testUsingContext('wildcard directories do not include subdirectories', () async {
|
||||
globals.fs.file('.packages').createSync();
|
||||
createPackageConfig(globals.fs);
|
||||
globals.fs.file('pubspec.yaml').writeAsStringSync(
|
||||
'''
|
||||
name: test
|
||||
@ -104,7 +129,7 @@ flutter:
|
||||
}
|
||||
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
await bundle.build(packageConfigPath: '.packages');
|
||||
await bundle.build(packageConfigPath: '.dart_tool/package_config.json');
|
||||
|
||||
expect(bundle.entries.keys, unorderedEquals(<String>[
|
||||
'AssetManifest.json',
|
||||
@ -121,7 +146,7 @@ flutter:
|
||||
});
|
||||
|
||||
testUsingContext('wildcard directories are updated when filesystem changes', () async {
|
||||
final File packageFile = globals.fs.file('.packages')..createSync();
|
||||
final File packageFile = createPackageConfig(globals.fs);
|
||||
globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true);
|
||||
globals.fs.file('pubspec.yaml')
|
||||
..createSync()
|
||||
@ -132,7 +157,7 @@ flutter:
|
||||
- assets/foo/
|
||||
''');
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
await bundle.build(packageConfigPath: '.packages');
|
||||
await bundle.build(packageConfigPath: '.dart_tool/package_config.json');
|
||||
expect(bundle.entries.keys, unorderedEquals(<String>['AssetManifest.json',
|
||||
'AssetManifest.bin', 'FontManifest.json', 'NOTICES.Z', 'assets/foo/bar.txt']));
|
||||
// Simulate modifying the files by updating the filestat time manually.
|
||||
@ -141,7 +166,7 @@ flutter:
|
||||
..setLastModifiedSync(packageFile.lastModifiedSync().add(const Duration(hours: 1)));
|
||||
|
||||
expect(bundle.needsBuild(), true);
|
||||
await bundle.build(packageConfigPath: '.packages');
|
||||
await bundle.build(packageConfigPath: '.dart_tool/package_config.json');
|
||||
expect(bundle.entries.keys, unorderedEquals(<String>['AssetManifest.json',
|
||||
'AssetManifest.bin', 'FontManifest.json', 'NOTICES.Z', 'assets/foo/bar.txt',
|
||||
'assets/foo/fizz.txt']));
|
||||
@ -161,9 +186,9 @@ flutter:
|
||||
assets:
|
||||
- assets/foo/
|
||||
''');
|
||||
globals.fs.file('.packages').createSync();
|
||||
final File packageConfig = createPackageConfig(globals.fs);
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
await bundle.build(packageConfigPath: '.packages');
|
||||
await bundle.build(packageConfigPath: '.dart_tool/package_config.json');
|
||||
expect(bundle.entries.keys, unorderedEquals(<String>['AssetManifest.json',
|
||||
'AssetManifest.bin', 'FontManifest.json', 'NOTICES.Z', 'assets/foo/bar.txt']));
|
||||
expect(bundle.needsBuild(), false);
|
||||
@ -177,15 +202,14 @@ flutter:
|
||||
name: example''')
|
||||
..setLastModifiedSync(modifiedTime);
|
||||
|
||||
// touch .packages to make sure its change time is after pubspec.yaml's
|
||||
globals.fs.file('.packages')
|
||||
.setLastModifiedSync(modifiedTime);
|
||||
// touch the package config to make sure its change time is after pubspec.yaml's
|
||||
packageConfig.setLastModifiedSync(modifiedTime);
|
||||
|
||||
// Even though the previous file was removed, it is left in the
|
||||
// asset manifest and not updated. This is due to the devfs not
|
||||
// supporting file deletion.
|
||||
expect(bundle.needsBuild(), true);
|
||||
await bundle.build(packageConfigPath: '.packages');
|
||||
await bundle.build(packageConfigPath: '.dart_tool/package_config.json');
|
||||
expect(bundle.entries.keys, unorderedEquals(<String>['AssetManifest.json',
|
||||
'AssetManifest.bin', 'FontManifest.json', 'NOTICES.Z', 'assets/foo/bar.txt']));
|
||||
}, overrides: <Type, Generator>{
|
||||
@ -208,9 +232,9 @@ flutter:
|
||||
assets:
|
||||
- assets/foo/
|
||||
''');
|
||||
globals.fs.file('.packages').createSync();
|
||||
createPackageConfig(globals.fs);
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
await bundle.build(packageConfigPath: '.packages');
|
||||
await bundle.build(packageConfigPath: '.dart_tool/package_config.json');
|
||||
expect(bundle.entries.keys, unorderedEquals(<String>['AssetManifest.json',
|
||||
'AssetManifest.bin', 'FontManifest.json', 'NOTICES.Z', 'assets/foo/bar.txt']));
|
||||
expect(bundle.needsBuild(), false);
|
||||
@ -221,7 +245,7 @@ flutter:
|
||||
});
|
||||
|
||||
testUsingContext('deferred assets are parsed', () async {
|
||||
globals.fs.file('.packages').createSync();
|
||||
createPackageConfig(globals.fs);
|
||||
globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true);
|
||||
globals.fs.file(globals.fs.path.join('assets', 'bar', 'barbie.txt')).createSync(recursive: true);
|
||||
globals.fs.file(globals.fs.path.join('assets', 'wild', 'dash.txt')).createSync(recursive: true);
|
||||
@ -244,7 +268,7 @@ flutter:
|
||||
platform: globals.platform,
|
||||
splitDeferredAssets: true,
|
||||
).createBundle();
|
||||
await bundle.build(packageConfigPath: '.packages', deferredComponentsEnabled: true);
|
||||
await bundle.build(packageConfigPath: '.dart_tool/package_config.json', deferredComponentsEnabled: true);
|
||||
expect(bundle.entries.keys, unorderedEquals(<String>['AssetManifest.json',
|
||||
'AssetManifest.bin', 'FontManifest.json', 'NOTICES.Z', 'assets/foo/bar.txt']));
|
||||
expect(bundle.deferredComponentsEntries.length, 1);
|
||||
@ -257,7 +281,7 @@ flutter:
|
||||
});
|
||||
|
||||
testUsingContext('deferred assets are parsed regularly when splitDeferredAssets Disabled', () async {
|
||||
globals.fs.file('.packages').createSync();
|
||||
createPackageConfig(globals.fs);
|
||||
globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true);
|
||||
globals.fs.file(globals.fs.path.join('assets', 'bar', 'barbie.txt')).createSync(recursive: true);
|
||||
globals.fs.file(globals.fs.path.join('assets', 'wild', 'dash.txt')).createSync(recursive: true);
|
||||
@ -275,7 +299,7 @@ flutter:
|
||||
- assets/wild/
|
||||
''');
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
await bundle.build(packageConfigPath: '.packages');
|
||||
await bundle.build(packageConfigPath: '.dart_tool/package_config.json');
|
||||
expect(bundle.entries.keys, unorderedEquals(<String>['assets/foo/bar.txt',
|
||||
'assets/bar/barbie.txt', 'assets/wild/dash.txt', 'AssetManifest.json',
|
||||
'AssetManifest.bin', 'FontManifest.json', 'NOTICES.Z']));
|
||||
@ -288,7 +312,7 @@ flutter:
|
||||
});
|
||||
|
||||
testUsingContext('deferred assets wildcard parsed', () async {
|
||||
final File packageFile = globals.fs.file('.packages')..createSync();
|
||||
final File packageFile = createPackageConfig(globals.fs);
|
||||
globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true);
|
||||
globals.fs.file(globals.fs.path.join('assets', 'bar', 'barbie.txt')).createSync(recursive: true);
|
||||
globals.fs.file(globals.fs.path.join('assets', 'wild', 'dash.txt')).createSync(recursive: true);
|
||||
@ -311,7 +335,7 @@ flutter:
|
||||
platform: globals.platform,
|
||||
splitDeferredAssets: true,
|
||||
).createBundle();
|
||||
await bundle.build(packageConfigPath: '.packages', deferredComponentsEnabled: true);
|
||||
await bundle.build(packageConfigPath: '.dart_tool/package_config.json', deferredComponentsEnabled: true);
|
||||
expect(bundle.entries.keys, unorderedEquals(<String>['assets/foo/bar.txt',
|
||||
'AssetManifest.json', 'AssetManifest.bin', 'FontManifest.json', 'NOTICES.Z']));
|
||||
expect(bundle.deferredComponentsEntries.length, 1);
|
||||
@ -324,7 +348,7 @@ flutter:
|
||||
..setLastModifiedSync(packageFile.lastModifiedSync().add(const Duration(hours: 1)));
|
||||
|
||||
expect(bundle.needsBuild(), true);
|
||||
await bundle.build(packageConfigPath: '.packages', deferredComponentsEnabled: true);
|
||||
await bundle.build(packageConfigPath: '.dart_tool/package_config.json', deferredComponentsEnabled: true);
|
||||
|
||||
expect(bundle.entries.keys, unorderedEquals(<String>['assets/foo/bar.txt',
|
||||
'AssetManifest.json', 'AssetManifest.bin', 'FontManifest.json', 'NOTICES.Z']));
|
||||
@ -348,7 +372,7 @@ flutter:
|
||||
userMessages: UserMessages(),
|
||||
);
|
||||
|
||||
fileSystem.file('.packages').createSync();
|
||||
createPackageConfig(fileSystem);
|
||||
fileSystem.file('pubspec.yaml')
|
||||
..createSync()
|
||||
..writeAsStringSync(r'''
|
||||
@ -366,7 +390,7 @@ flutter:
|
||||
|
||||
expect(
|
||||
() => bundle.build(
|
||||
packageConfigPath: '.packages',
|
||||
packageConfigPath: '.dart_tool/package_config.json',
|
||||
flutterProject: FlutterProject.fromDirectoryTest(
|
||||
fileSystem.currentDirectory,
|
||||
),
|
||||
@ -400,7 +424,7 @@ flutter:
|
||||
fileSystem: fileSystem,
|
||||
userMessages: UserMessages(),
|
||||
);
|
||||
fileSystem.file('.packages').createSync();
|
||||
createPackageConfig(fileSystem);
|
||||
fileSystem.file('pubspec.yaml')
|
||||
..createSync()
|
||||
..writeAsStringSync(r'''
|
||||
@ -418,7 +442,7 @@ flutter:
|
||||
|
||||
expect(
|
||||
() => bundle.build(
|
||||
packageConfigPath: '.packages',
|
||||
packageConfigPath: '.dart_tool/package_config.json',
|
||||
flutterProject: FlutterProject.fromDirectoryTest(
|
||||
fileSystem.currentDirectory,
|
||||
),
|
||||
@ -436,7 +460,7 @@ flutter:
|
||||
|
||||
final BufferLogger logger = BufferLogger.test();
|
||||
final FakePlatform platform = FakePlatform();
|
||||
fileSystem.file('.packages').createSync();
|
||||
createPackageConfig(fileSystem);
|
||||
fileSystem.file('pubspec.yaml')
|
||||
..createSync()
|
||||
..writeAsStringSync(r'''
|
||||
@ -459,7 +483,7 @@ flutter:
|
||||
);
|
||||
|
||||
await bundle.build(
|
||||
packageConfigPath: '.packages',
|
||||
packageConfigPath: '.dart_tool/package_config.json',
|
||||
flutterProject: FlutterProject.fromDirectoryTest(
|
||||
fileSystem.currentDirectory,
|
||||
),
|
||||
@ -468,7 +492,7 @@ flutter:
|
||||
expect(bundle.entries['my-asset.txt']!.content.isModified, isTrue);
|
||||
|
||||
await bundle.build(
|
||||
packageConfigPath: '.packages',
|
||||
packageConfigPath: '.dart_tool/package_config.json',
|
||||
flutterProject: FlutterProject.fromDirectoryTest(
|
||||
fileSystem.currentDirectory,
|
||||
),
|
||||
@ -487,7 +511,7 @@ flutter:
|
||||
''');
|
||||
|
||||
await bundle.build(
|
||||
packageConfigPath: '.packages',
|
||||
packageConfigPath: '.dart_tool/package_config.json',
|
||||
flutterProject: FlutterProject.fromDirectoryTest(
|
||||
fileSystem.currentDirectory,
|
||||
),
|
||||
@ -513,7 +537,7 @@ flutter:
|
||||
..writeAsStringSync('');
|
||||
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
await bundle.build(packageConfigPath: '.packages', targetPlatform: TargetPlatform.web_javascript);
|
||||
await bundle.build(packageConfigPath: '.dart_tool/package_config.json', targetPlatform: TargetPlatform.web_javascript);
|
||||
|
||||
expect(bundle.entries.keys,
|
||||
unorderedEquals(<String>[
|
||||
@ -537,7 +561,7 @@ flutter:
|
||||
});
|
||||
|
||||
testUsingContext('pubspec contains an asset', () async {
|
||||
globals.fs.file('.packages').createSync();
|
||||
createPackageConfig(globals.fs);
|
||||
globals.fs.file('pubspec.yaml').writeAsStringSync(r'''
|
||||
name: test
|
||||
dependencies:
|
||||
@ -552,7 +576,7 @@ flutter:
|
||||
).createSync(recursive: true);
|
||||
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
await bundle.build(packageConfigPath: '.packages', targetPlatform: TargetPlatform.web_javascript);
|
||||
await bundle.build(packageConfigPath: '.dart_tool/package_config.json', targetPlatform: TargetPlatform.web_javascript);
|
||||
|
||||
expect(bundle.entries.keys,
|
||||
unorderedEquals(<String>[
|
||||
@ -618,7 +642,7 @@ flutter:
|
||||
});
|
||||
|
||||
testUsingContext('does not unnecessarily recreate asset manifest, font manifest, license', () async {
|
||||
globals.fs.file('.packages').createSync();
|
||||
createPackageConfig(globals.fs);
|
||||
globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true);
|
||||
globals.fs.file('pubspec.yaml')
|
||||
..createSync()
|
||||
@ -629,13 +653,13 @@ assets:
|
||||
- assets/foo/bar.txt
|
||||
''');
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
await bundle.build(packageConfigPath: '.packages');
|
||||
await bundle.build(packageConfigPath: '.dart_tool/package_config.json');
|
||||
|
||||
final AssetBundleEntry? assetManifest = bundle.entries['AssetManifest.json'];
|
||||
final AssetBundleEntry? fontManifest = bundle.entries['FontManifest.json'];
|
||||
final AssetBundleEntry? license = bundle.entries['NOTICES'];
|
||||
|
||||
await bundle.build(packageConfigPath: '.packages');
|
||||
await bundle.build(packageConfigPath: '.dart_tool/package_config.json');
|
||||
|
||||
expect(assetManifest, bundle.entries['AssetManifest.json']);
|
||||
expect(fontManifest, bundle.entries['FontManifest.json']);
|
||||
@ -648,7 +672,7 @@ assets:
|
||||
|
||||
testUsingContext('inserts dummy file into additionalDependencies when '
|
||||
'wildcards are used', () async {
|
||||
globals.fs.file('.packages').createSync();
|
||||
createPackageConfig(globals.fs);
|
||||
globals.fs.file(globals.fs.path.join('assets', 'bar.txt')).createSync(recursive: true);
|
||||
globals.fs.file('pubspec.yaml')
|
||||
..createSync()
|
||||
@ -660,7 +684,7 @@ flutter:
|
||||
''');
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
|
||||
expect(await bundle.build(packageConfigPath: '.packages'), 0);
|
||||
expect(await bundle.build(packageConfigPath: '.dart_tool/package_config.json'), 0);
|
||||
expect(bundle.additionalDependencies.single.path, contains('DOES_NOT_EXIST_RERUN_FOR_WILDCARD'));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => MemoryFileSystem.test(),
|
||||
@ -670,7 +694,7 @@ flutter:
|
||||
|
||||
testUsingContext('Does not insert dummy file into additionalDependencies '
|
||||
'when wildcards are not used', () async {
|
||||
globals.fs.file('.packages').createSync();
|
||||
createPackageConfig(globals.fs);
|
||||
globals.fs.file(globals.fs.path.join('assets', 'bar.txt')).createSync(recursive: true);
|
||||
globals.fs.file('pubspec.yaml')
|
||||
..createSync()
|
||||
@ -682,7 +706,7 @@ flutter:
|
||||
''');
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
|
||||
expect(await bundle.build(packageConfigPath: '.packages'), 0);
|
||||
expect(await bundle.build(packageConfigPath: '.dart_tool/package_config.json'), 0);
|
||||
expect(bundle.additionalDependencies, isEmpty);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => MemoryFileSystem.test(),
|
||||
@ -715,7 +739,7 @@ flutter:
|
||||
});
|
||||
|
||||
testUsingContext('Including a shader triggers the shader compiler', () async {
|
||||
fileSystem.file('.packages').createSync();
|
||||
createPackageConfig(fileSystem);
|
||||
fileSystem.file('pubspec.yaml')
|
||||
..createSync()
|
||||
..writeAsStringSync(r'''
|
||||
@ -726,7 +750,7 @@ flutter:
|
||||
''');
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
|
||||
expect(await bundle.build(packageConfigPath: '.packages'), 0);
|
||||
expect(await bundle.build(packageConfigPath: '.dart_tool/package_config.json'), 0);
|
||||
|
||||
await writeBundle(
|
||||
output,
|
||||
@ -768,7 +792,7 @@ flutter:
|
||||
});
|
||||
|
||||
testUsingContext('Included shaders are compiled for the web', () async {
|
||||
fileSystem.file('.packages').createSync();
|
||||
createPackageConfig(fileSystem);
|
||||
fileSystem.file('pubspec.yaml')
|
||||
..createSync()
|
||||
..writeAsStringSync(r'''
|
||||
@ -779,7 +803,7 @@ flutter:
|
||||
''');
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
|
||||
expect(await bundle.build(packageConfigPath: '.packages', targetPlatform: TargetPlatform.web_javascript), 0);
|
||||
expect(await bundle.build(packageConfigPath: '.dart_tool/package_config.json', targetPlatform: TargetPlatform.web_javascript), 0);
|
||||
|
||||
await writeBundle(
|
||||
output,
|
||||
@ -820,7 +844,7 @@ flutter:
|
||||
});
|
||||
|
||||
testUsingContext('Material shaders are compiled for the web', () async {
|
||||
fileSystem.file('.packages').createSync();
|
||||
createPackageConfig(fileSystem);
|
||||
|
||||
final String materialIconsPath = fileSystem.path.join(
|
||||
getFlutterRoot(),
|
||||
@ -867,7 +891,7 @@ flutter:
|
||||
''');
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
|
||||
expect(await bundle.build(packageConfigPath: '.packages', targetPlatform: TargetPlatform.web_javascript), 0);
|
||||
expect(await bundle.build(packageConfigPath: '.dart_tool/package_config.json', targetPlatform: TargetPlatform.web_javascript), 0);
|
||||
|
||||
await writeBundle(
|
||||
output,
|
||||
@ -891,10 +915,13 @@ flutter:
|
||||
|
||||
testUsingContext('Does not insert dummy file into additionalDependencies '
|
||||
'when wildcards are used by dependencies', () async {
|
||||
globals.fs.file('.packages').writeAsStringSync(r'''
|
||||
example:lib/
|
||||
foo:foo/lib/
|
||||
''');
|
||||
createPackageConfig(
|
||||
globals.fs,
|
||||
packages: <String, String> {
|
||||
'example': '',
|
||||
'foo': 'foo',
|
||||
},
|
||||
);
|
||||
globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.txt'))
|
||||
.createSync(recursive: true);
|
||||
globals.fs.file('pubspec.yaml')
|
||||
@ -916,7 +943,7 @@ flutter:
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
globals.fs.file('foo/bar/fizz.txt').createSync(recursive: true);
|
||||
|
||||
expect(await bundle.build(packageConfigPath: '.packages'), 0);
|
||||
expect(await bundle.build(packageConfigPath: '.dart_tool/package_config.json'), 0);
|
||||
expect(bundle.additionalDependencies, isEmpty);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => MemoryFileSystem.test(),
|
||||
@ -925,10 +952,13 @@ flutter:
|
||||
});
|
||||
|
||||
testUsingContext('does not track wildcard directories from dependencies', () async {
|
||||
globals.fs.file('.packages').writeAsStringSync(r'''
|
||||
example:lib/
|
||||
foo:foo/lib/
|
||||
''');
|
||||
createPackageConfig(
|
||||
globals.fs,
|
||||
packages: <String, String> {
|
||||
'example': '',
|
||||
'foo': 'foo',
|
||||
},
|
||||
);
|
||||
globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.txt'))
|
||||
.createSync(recursive: true);
|
||||
globals.fs.file('pubspec.yaml')
|
||||
@ -950,7 +980,7 @@ flutter:
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
globals.fs.file('foo/bar/fizz.txt').createSync(recursive: true);
|
||||
|
||||
await bundle.build(packageConfigPath: '.packages');
|
||||
await bundle.build(packageConfigPath: '.dart_tool/package_config.json');
|
||||
|
||||
expect(bundle.entries.keys, unorderedEquals(<String>['packages/foo/bar/fizz.txt',
|
||||
'AssetManifest.json', 'AssetManifest.bin', 'FontManifest.json', 'NOTICES.Z']));
|
||||
@ -969,10 +999,13 @@ flutter:
|
||||
|
||||
testUsingContext('reports package that causes asset bundle error when it is '
|
||||
'a dependency', () async {
|
||||
globals.fs.file('.packages').writeAsStringSync(r'''
|
||||
example:lib/
|
||||
foo:foo/lib/
|
||||
''');
|
||||
createPackageConfig(
|
||||
globals.fs,
|
||||
packages: <String, String> {
|
||||
'example': '',
|
||||
'foo': 'foo',
|
||||
},
|
||||
);
|
||||
globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.txt'))
|
||||
.createSync(recursive: true);
|
||||
globals.fs.file('pubspec.yaml')
|
||||
@ -993,7 +1026,7 @@ flutter:
|
||||
''');
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
|
||||
expect(await bundle.build(packageConfigPath: '.packages'), 1);
|
||||
expect(await bundle.build(packageConfigPath: '.dart_tool/package_config.json'), 1);
|
||||
expect(testLogger.errorText, contains('This asset was included from package foo'));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => MemoryFileSystem.test(),
|
||||
@ -1003,9 +1036,13 @@ flutter:
|
||||
|
||||
testUsingContext('does not report package that causes asset bundle error '
|
||||
'when it is from own pubspec', () async {
|
||||
globals.fs.file('.packages').writeAsStringSync(r'''
|
||||
example:lib/
|
||||
''');
|
||||
createPackageConfig(
|
||||
globals.fs,
|
||||
packages: <String, String> {
|
||||
'example': '',
|
||||
'foo': 'foo',
|
||||
},
|
||||
);
|
||||
globals.fs.file('pubspec.yaml')
|
||||
..createSync()
|
||||
..writeAsStringSync(r'''
|
||||
@ -1016,7 +1053,7 @@ flutter:
|
||||
''');
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
|
||||
expect(await bundle.build(packageConfigPath: '.packages'), 1);
|
||||
expect(await bundle.build(packageConfigPath: '.dart_tool/package_config.json'), 1);
|
||||
expect(testLogger.errorText, isNot(contains('This asset was included from')));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => MemoryFileSystem.test(),
|
||||
@ -1026,10 +1063,13 @@ flutter:
|
||||
|
||||
testUsingContext('does not include Material Design assets if uses-material-design: true is '
|
||||
'specified only by a dependency', () async {
|
||||
globals.fs.file('.packages').writeAsStringSync(r'''
|
||||
example:lib/
|
||||
foo:foo/lib/
|
||||
''');
|
||||
createPackageConfig(
|
||||
globals.fs,
|
||||
packages: <String, String> {
|
||||
'example': '',
|
||||
'foo': 'foo',
|
||||
},
|
||||
);
|
||||
globals.fs.file('pubspec.yaml')
|
||||
..createSync()
|
||||
..writeAsStringSync(r'''
|
||||
@ -1050,7 +1090,7 @@ flutter:
|
||||
''');
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
|
||||
expect(await bundle.build(packageConfigPath: '.packages'), 0);
|
||||
expect(await bundle.build(packageConfigPath: '.dart_tool/package_config.json'), 0);
|
||||
expect((bundle.entries['FontManifest.json']!.content as DevFSStringContent).string, '[]');
|
||||
expect((bundle.entries['AssetManifest.json']!.content as DevFSStringContent).string, '{}');
|
||||
expect(testLogger.errorText, contains(
|
||||
@ -1063,9 +1103,12 @@ flutter:
|
||||
});
|
||||
|
||||
testUsingContext('does not include assets in project directories as asset variants', () async {
|
||||
globals.fs.file('.packages').writeAsStringSync(r'''
|
||||
example:lib/
|
||||
''');
|
||||
createPackageConfig(
|
||||
globals.fs,
|
||||
packages: <String, String> {
|
||||
'example': '',
|
||||
},
|
||||
);
|
||||
globals.fs.file('pubspec.yaml')
|
||||
..createSync()
|
||||
..writeAsStringSync(r'''
|
||||
@ -1087,7 +1130,7 @@ flutter:
|
||||
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
|
||||
expect(await bundle.build(packageConfigPath: '.packages'), 0);
|
||||
expect(await bundle.build(packageConfigPath: '.dart_tool/package_config.json'), 0);
|
||||
expect(bundle.entries.keys, unorderedEquals(<String>['assets/foo.txt',
|
||||
'AssetManifest.json', 'AssetManifest.bin', 'FontManifest.json', 'NOTICES.Z']));
|
||||
}, overrides: <Type, Generator>{
|
||||
@ -1097,9 +1140,12 @@ flutter:
|
||||
});
|
||||
|
||||
testUsingContext('deferred and regular assets are included in manifest alphabetically', () async {
|
||||
globals.fs.file('.packages').writeAsStringSync(r'''
|
||||
example:lib/
|
||||
''');
|
||||
createPackageConfig(
|
||||
globals.fs,
|
||||
packages: <String, String> {
|
||||
'example': '',
|
||||
},
|
||||
);
|
||||
globals.fs.file('pubspec.yaml')
|
||||
..createSync()
|
||||
..writeAsStringSync(r'''
|
||||
@ -1122,7 +1168,7 @@ flutter:
|
||||
globals.fs.file('assets/zebra.jpg').createSync();
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
|
||||
expect(await bundle.build(packageConfigPath: '.packages'), 0);
|
||||
expect(await bundle.build(packageConfigPath: '.dart_tool/package_config.json'), 0);
|
||||
expect((bundle.entries['FontManifest.json']!.content as DevFSStringContent).string, '[]');
|
||||
// The assets from deferred components and regular assets
|
||||
// are both included in alphabetical order
|
||||
|
@ -52,8 +52,14 @@ void main() {
|
||||
fileSystem: fs,
|
||||
userMessages: UserMessages(),
|
||||
);
|
||||
|
||||
fs.file('.packages').createSync();
|
||||
fs.directory('.dart_tool').childFile('package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": []
|
||||
}
|
||||
''');
|
||||
});
|
||||
|
||||
void createPubspec({
|
||||
@ -99,7 +105,7 @@ ${assets.map((String entry) => ' - $entry').join('\n')}
|
||||
);
|
||||
|
||||
await bundle.build(
|
||||
packageConfigPath: '.packages',
|
||||
packageConfigPath: '.dart_tool/package_config.json',
|
||||
flutterProject: FlutterProject.fromDirectoryTest(fs.currentDirectory),
|
||||
);
|
||||
|
||||
@ -154,7 +160,7 @@ ${assets.map((String entry) => ' - $entry').join('\n')}
|
||||
);
|
||||
|
||||
await bundle.build(
|
||||
packageConfigPath: '.packages',
|
||||
packageConfigPath: '.dart_tool/package_config.json',
|
||||
flutterProject: FlutterProject.fromDirectoryTest(fs.currentDirectory),
|
||||
);
|
||||
|
||||
@ -210,7 +216,7 @@ ${assets.map((String entry) => ' - $entry').join('\n')}
|
||||
);
|
||||
|
||||
await bundle.build(
|
||||
packageConfigPath: '.packages',
|
||||
packageConfigPath: '.dart_tool/package_config.json',
|
||||
flutterProject: FlutterProject.fromDirectoryTest(fs.currentDirectory),
|
||||
);
|
||||
|
||||
@ -256,7 +262,7 @@ ${assets.map((String entry) => ' - $entry').join('\n')}
|
||||
);
|
||||
|
||||
await bundle.build(
|
||||
packageConfigPath: '.packages',
|
||||
packageConfigPath: '.dart_tool/package_config.json',
|
||||
flutterProject: FlutterProject.fromDirectoryTest(fs.currentDirectory),
|
||||
);
|
||||
|
||||
@ -290,7 +296,14 @@ ${assets.map((String entry) => ' - $entry').join('\n')}
|
||||
userMessages: UserMessages()
|
||||
);
|
||||
|
||||
fs.file('.packages').createSync();
|
||||
fs.directory('.dart_tool').childFile('package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": []
|
||||
}
|
||||
''');
|
||||
|
||||
fs.file('pubspec.yaml').writeAsStringSync(
|
||||
'''
|
||||
@ -328,7 +341,7 @@ flutter:
|
||||
);
|
||||
|
||||
await bundle.build(
|
||||
packageConfigPath: '.packages',
|
||||
packageConfigPath: '.dart_tool/package_config.json',
|
||||
flutterProject: FlutterProject.fromDirectoryTest(fs.currentDirectory),
|
||||
);
|
||||
|
||||
|
@ -44,7 +44,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWithoutContext('app font uses local font file', () async {
|
||||
final String packagesPath = fileSystem.path.join('main', '.packages');
|
||||
final String packagesPath = fileSystem.path.join('main', '.dart_tool', 'package_config.json');
|
||||
final String manifestPath =
|
||||
fileSystem.path.join('main', 'pubspec.yaml');
|
||||
final ManifestAssetBundle assetBundle = ManifestAssetBundle(
|
||||
@ -137,13 +137,13 @@ dependencies:
|
||||
);
|
||||
});
|
||||
|
||||
testWithoutContext('handles empty pubspec with .packages', () async {
|
||||
final String packagesPath = fileSystem.path.join('fuchsia_test', 'main', '.packages');
|
||||
testWithoutContext('handles empty pubspec with .dart_tool/package_config.json', () async {
|
||||
final String packageConfigPath = fileSystem.path.join('fuchsia_test', 'main', '.dart_tool', 'package_config.json');
|
||||
final String manifestPath =
|
||||
fileSystem.path.join('fuchsia_test', 'main', 'pubspec.yaml');
|
||||
|
||||
fileSystem.directory(fileSystem.file(manifestPath)).parent.createSync(recursive: true);
|
||||
fileSystem.directory(fileSystem.file(packagesPath)).parent.createSync(recursive: true);
|
||||
fileSystem.directory(fileSystem.file(packageConfigPath)).parent.createSync(recursive: true);
|
||||
|
||||
final ManifestAssetBundle assetBundle = ManifestAssetBundle(
|
||||
logger: logger,
|
||||
@ -155,7 +155,7 @@ dependencies:
|
||||
|
||||
await assetBundle.build(
|
||||
manifestPath: manifestPath, // file doesn't exist
|
||||
packageConfigPath: packagesPath,
|
||||
packageConfigPath: packageConfigPath,
|
||||
flutterProject: FlutterProject.fromDirectoryTest(fileSystem.file(manifestPath).parent),
|
||||
);
|
||||
|
||||
@ -203,7 +203,7 @@ dependencies:
|
||||
);
|
||||
|
||||
await assetBundle.build(
|
||||
packageConfigPath: '.packages',
|
||||
packageConfigPath: '.dart_tool/package_config.json',
|
||||
targetPlatform: TargetPlatform.android_arm,
|
||||
flutterProject: FlutterProject.fromDirectoryTest(fileSystem.currentDirectory),
|
||||
);
|
||||
@ -248,7 +248,7 @@ dependencies:
|
||||
);
|
||||
|
||||
await assetBundle.build(
|
||||
packageConfigPath: '.packages',
|
||||
packageConfigPath: '.dart_tool/package_config.json',
|
||||
targetPlatform: TargetPlatform.web_javascript,
|
||||
flutterProject: FlutterProject.fromDirectoryTest(fileSystem.currentDirectory),
|
||||
);
|
||||
|
@ -185,7 +185,6 @@ void main() {
|
||||
));
|
||||
environment.buildDir.createSync(recursive: true);
|
||||
environment.buildDir.childFile('app.dill').createSync();
|
||||
environment.projectDir.childFile('.packages').writeAsStringSync('\n');
|
||||
const AndroidAot androidAot = AndroidAot(TargetPlatform.android_arm64, BuildMode.release);
|
||||
|
||||
await androidAot.build(environment);
|
||||
@ -224,7 +223,6 @@ void main() {
|
||||
));
|
||||
environment.buildDir.createSync(recursive: true);
|
||||
environment.buildDir.childFile('app.dill').createSync();
|
||||
environment.projectDir.childFile('.packages').writeAsStringSync('\n');
|
||||
const AndroidAot androidAot = AndroidAot(TargetPlatform.android_arm64, BuildMode.release);
|
||||
|
||||
await androidAot.build(environment);
|
||||
@ -266,7 +264,6 @@ void main() {
|
||||
));
|
||||
environment.buildDir.createSync(recursive: true);
|
||||
environment.buildDir.childFile('app.dill').createSync();
|
||||
environment.projectDir.childFile('.packages').writeAsStringSync('\n');
|
||||
|
||||
await const AndroidAot(TargetPlatform.android_arm64, BuildMode.release)
|
||||
.build(environment);
|
||||
@ -304,7 +301,6 @@ void main() {
|
||||
));
|
||||
environment.buildDir.createSync(recursive: true);
|
||||
environment.buildDir.childFile('app.dill').createSync();
|
||||
environment.projectDir.childFile('.packages').writeAsStringSync('\n');
|
||||
|
||||
await const AndroidAot(TargetPlatform.android_arm64, BuildMode.release)
|
||||
.build(environment);
|
||||
@ -529,7 +525,10 @@ void main() {
|
||||
.file(artifacts.getArtifactPath(Artifact.isolateSnapshotData, mode: BuildMode.debug))
|
||||
.createSync(recursive: true);
|
||||
fileSystem.file('pubspec.yaml').writeAsStringSync('name: hello\nflutter:\n shaders:\n - shader.glsl');
|
||||
fileSystem.file('.packages').writeAsStringSync('\n');
|
||||
fileSystem
|
||||
.directory('.dart_tool')
|
||||
.childFile('package_config.json')
|
||||
.createSync(recursive: true);
|
||||
fileSystem.file('shader.glsl').writeAsStringSync('test');
|
||||
|
||||
processManager.addCommands(<FakeCommand>[
|
||||
|
@ -49,8 +49,10 @@ void main() {
|
||||
.createSync(recursive: true);
|
||||
fileSystem.file('assets/wildcard/#bar.png')
|
||||
.createSync(recursive: true);
|
||||
fileSystem.file('.packages')
|
||||
.createSync();
|
||||
fileSystem
|
||||
.directory('.dart_tool')
|
||||
.childFile('package_config.json')
|
||||
.createSync(recursive: true);
|
||||
fileSystem.file('pubspec.yaml')
|
||||
..createSync()
|
||||
..writeAsStringSync('''
|
||||
@ -65,8 +67,22 @@ flutter:
|
||||
});
|
||||
|
||||
testUsingContext('includes LICENSE file inputs in dependencies', () async {
|
||||
fileSystem.file('.packages')
|
||||
.writeAsStringSync('foo:file:///bar/lib');
|
||||
fileSystem
|
||||
.directory('.dart_tool')
|
||||
.childFile('package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": [
|
||||
{
|
||||
"name": "foo",
|
||||
"rootUri": "file:///bar",
|
||||
"packageUri": "lib/"
|
||||
}
|
||||
]
|
||||
}
|
||||
''');
|
||||
fileSystem.file('bar/LICENSE')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('THIS IS A LICENSE');
|
||||
@ -185,7 +201,10 @@ flutter:
|
||||
},
|
||||
);
|
||||
|
||||
await fileSystem.file('.packages').create();
|
||||
fileSystem
|
||||
.directory('.dart_tool')
|
||||
.childFile('package_config.json')
|
||||
.createSync(recursive: true);
|
||||
|
||||
fileSystem.file('pubspec.yaml')
|
||||
..createSync()
|
||||
@ -272,7 +291,10 @@ flutter:
|
||||
},
|
||||
);
|
||||
|
||||
await fileSystem.file('.packages').create();
|
||||
fileSystem
|
||||
.directory('.dart_tool')
|
||||
.childFile('package_config.json')
|
||||
.createSync(recursive: true);
|
||||
|
||||
fileSystem.file('pubspec.yaml')
|
||||
..createSync()
|
||||
@ -370,7 +392,10 @@ flutter:
|
||||
},
|
||||
);
|
||||
|
||||
await fileSystem.file('.packages').create();
|
||||
fileSystem
|
||||
.directory('.dart_tool')
|
||||
.childFile('package_config.json')
|
||||
.createSync(recursive: true);
|
||||
|
||||
fileSystem.file('pubspec.yaml')
|
||||
..createSync()
|
||||
|
@ -56,11 +56,6 @@ const String _kSamplePackageJson = '''
|
||||
}
|
||||
''';
|
||||
|
||||
const String _kSamplePackagesFile = '''
|
||||
path_provider_linux:/path_provider_linux/lib/
|
||||
path_provider_example:lib/
|
||||
''';
|
||||
|
||||
const String _kSamplePubspecFile = '''
|
||||
name: path_provider_example
|
||||
description: Demonstrates how to use the path_provider plugin.
|
||||
@ -177,8 +172,6 @@ void main() {
|
||||
|
||||
projectDir.childFile('pubspec.yaml').createSync();
|
||||
|
||||
projectDir.childFile('.packages').createSync();
|
||||
|
||||
final FlutterProject testProject = FlutterProject.fromDirectoryTest(projectDir);
|
||||
await DartPluginRegistrantTarget.test(testProject).build(environment);
|
||||
|
||||
@ -211,8 +204,6 @@ void main() {
|
||||
|
||||
projectDir.childFile('pubspec.yaml').writeAsStringSync(_kSamplePubspecFile);
|
||||
|
||||
projectDir.childFile('.packages').writeAsStringSync(_kSamplePackagesFile);
|
||||
|
||||
projectDir.childDirectory('lib').childFile('main.dart').createSync(recursive: true);
|
||||
|
||||
environment.fileSystem.currentDirectory
|
||||
@ -289,8 +280,6 @@ void main() {
|
||||
|
||||
final File pubspec = projectDir.childFile('pubspec.yaml')..writeAsStringSync(_kSamplePubspecFile);
|
||||
|
||||
final File packages = projectDir.childFile('.packages')..writeAsStringSync(_kSamplePackagesFile);
|
||||
|
||||
environment.fileSystem.currentDirectory
|
||||
.childDirectory('path_provider_linux')
|
||||
.childFile('pubspec.yaml')
|
||||
@ -308,7 +297,6 @@ void main() {
|
||||
|
||||
// Simulate a user removing everything from pubspec.yaml.
|
||||
pubspec.writeAsStringSync(_kEmptyPubspecFile);
|
||||
packages.writeAsStringSync(_kEmptyPackageJson);
|
||||
config.writeAsStringSync(_kEmptyPackageJson);
|
||||
|
||||
await DartPluginRegistrantTarget.test(testProject).build(environment);
|
||||
@ -337,8 +325,6 @@ void main() {
|
||||
|
||||
projectDir.childFile('pubspec.yaml').writeAsStringSync(_kSamplePubspecFile);
|
||||
|
||||
projectDir.childFile('.packages').writeAsStringSync(_kSamplePackagesFile);
|
||||
|
||||
projectDir.childDirectory('lib').childFile('main.dart').createSync(recursive: true);
|
||||
|
||||
environment.fileSystem.currentDirectory
|
||||
|
@ -196,7 +196,10 @@ void main() {
|
||||
.createSync();
|
||||
// Project info
|
||||
fileSystem.file('pubspec.yaml').writeAsStringSync('name: hello');
|
||||
fileSystem.file('.packages').writeAsStringSync('\n');
|
||||
fileSystem
|
||||
.directory('.dart_tool')
|
||||
.childFile('package_config.json')
|
||||
.createSync(recursive: true);
|
||||
// Plist file
|
||||
fileSystem.file(fileSystem.path.join('ios', 'Flutter', 'AppFrameworkInfo.plist'))
|
||||
.createSync(recursive: true);
|
||||
@ -271,7 +274,10 @@ void main() {
|
||||
.createSync();
|
||||
// Project info
|
||||
fileSystem.file('pubspec.yaml').writeAsStringSync('name: hello\nflutter:\n shaders:\n - shader.glsl');
|
||||
fileSystem.file('.packages').writeAsStringSync('\n');
|
||||
fileSystem
|
||||
.directory('.dart_tool')
|
||||
.childFile('package_config.json')
|
||||
.createSync(recursive: true);
|
||||
// Plist file
|
||||
fileSystem.file(fileSystem.path.join('ios', 'Flutter', 'AppFrameworkInfo.plist'))
|
||||
.createSync(recursive: true);
|
||||
@ -341,7 +347,10 @@ void main() {
|
||||
|
||||
// Project info
|
||||
fileSystem.file('pubspec.yaml').writeAsStringSync('name: hello');
|
||||
fileSystem.file('.packages').writeAsStringSync('\n');
|
||||
fileSystem
|
||||
.directory('.dart_tool')
|
||||
.childFile('package_config.json')
|
||||
.createSync(recursive: true);
|
||||
// Plist file
|
||||
fileSystem.file(fileSystem.path.join('ios', 'Flutter', 'AppFrameworkInfo.plist'))
|
||||
.createSync(recursive: true);
|
||||
|
@ -992,9 +992,6 @@ void main() {
|
||||
|
||||
expect(await pubDependencies.isUpToDate(fileSystem), false); // no package config
|
||||
|
||||
fileSystem.file('packages/flutter_tools/.packages')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('\n');
|
||||
fileSystem.file('packages/flutter_tools/.dart_tool/package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
|
@ -53,7 +53,7 @@ void main() {
|
||||
platform: FakePlatform(
|
||||
environment: <String, String>{},
|
||||
script: Uri.parse('package:flutter_tools/flutter_tools.dart'),
|
||||
packageConfig: 'flutter/packages/flutter_tools/.packages'
|
||||
packageConfig: 'flutter/packages/flutter_tools/.dart_tool/package_config.json'
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -64,7 +64,7 @@ void main() {
|
||||
'--enable-asserts',
|
||||
'--no-link-platform',
|
||||
'--packages',
|
||||
'.packages',
|
||||
'.dart_tool/package_config.json',
|
||||
'--verbosity=error',
|
||||
'file:///path/to/main.dart',
|
||||
], completer: completer),
|
||||
@ -77,7 +77,7 @@ void main() {
|
||||
trackWidgetCreation: false,
|
||||
dartDefines: const <String>[],
|
||||
packageConfig: PackageConfig.empty,
|
||||
packagesPath: '.packages',
|
||||
packagesPath: '.dart_tool/package_config.json',
|
||||
);
|
||||
stdoutHandler.compilerOutput?.complete(const CompilerOutput('', 0, <Uri>[]));
|
||||
completer.complete();
|
||||
@ -109,7 +109,7 @@ void main() {
|
||||
'--enable-asserts',
|
||||
'--no-link-platform',
|
||||
'--packages',
|
||||
'.packages',
|
||||
'.dart_tool/package_config.json',
|
||||
'--verbosity=error',
|
||||
'file:///path/to/main.dart',
|
||||
], completer: completer),
|
||||
@ -122,7 +122,7 @@ void main() {
|
||||
trackWidgetCreation: false,
|
||||
dartDefines: const <String>[],
|
||||
packageConfig: PackageConfig.empty,
|
||||
packagesPath: '.packages',
|
||||
packagesPath: '.dart_tool/package_config.json',
|
||||
);
|
||||
stdoutHandler.compilerOutput?.complete();
|
||||
completer.complete();
|
||||
@ -154,7 +154,7 @@ void main() {
|
||||
'--enable-asserts',
|
||||
'--no-link-platform',
|
||||
'--packages',
|
||||
'.packages',
|
||||
'.dart_tool/package_config.json',
|
||||
'--verbosity=error',
|
||||
'file:///path/to/main.dart',
|
||||
], completer: completer, exitCode: 127),
|
||||
@ -167,7 +167,7 @@ void main() {
|
||||
trackWidgetCreation: false,
|
||||
dartDefines: const <String>[],
|
||||
packageConfig: PackageConfig.empty,
|
||||
packagesPath: '.packages',
|
||||
packagesPath: '.dart_tool/package_config.json',
|
||||
);
|
||||
stdoutHandler.compilerOutput?.complete(const CompilerOutput('', 0, <Uri>[]));
|
||||
completer.complete();
|
||||
@ -202,7 +202,7 @@ void main() {
|
||||
'--aot',
|
||||
'--tfa',
|
||||
'--packages',
|
||||
'.packages',
|
||||
'.dart_tool/package_config.json',
|
||||
'--verbosity=error',
|
||||
'file:///path/to/main.dart',
|
||||
], completer: completer),
|
||||
@ -216,7 +216,7 @@ void main() {
|
||||
aot: true,
|
||||
dartDefines: const <String>[],
|
||||
packageConfig: PackageConfig.empty,
|
||||
packagesPath: '.packages',
|
||||
packagesPath: '.dart_tool/package_config.json',
|
||||
);
|
||||
stdoutHandler.compilerOutput?.complete(const CompilerOutput('', 0, <Uri>[]));
|
||||
completer.complete();
|
||||
@ -251,7 +251,7 @@ void main() {
|
||||
'--aot',
|
||||
'--tfa',
|
||||
'--packages',
|
||||
'.packages',
|
||||
'.dart_tool/package_config.json',
|
||||
'--verbosity=error',
|
||||
'file:///path/to/main.dart',
|
||||
], completer: completer),
|
||||
@ -265,7 +265,7 @@ void main() {
|
||||
aot: true,
|
||||
dartDefines: const <String>[],
|
||||
packageConfig: PackageConfig.empty,
|
||||
packagesPath: '.packages',
|
||||
packagesPath: '.dart_tool/package_config.json',
|
||||
);
|
||||
stdoutHandler.compilerOutput?.complete(const CompilerOutput('', 0, <Uri>[]));
|
||||
completer.complete();
|
||||
@ -299,7 +299,7 @@ void main() {
|
||||
'--enable-asserts',
|
||||
'--no-link-platform',
|
||||
'--packages',
|
||||
'.packages',
|
||||
'.dart_tool/package_config.json',
|
||||
'--verbosity=error',
|
||||
'file:///path/to/main.dart',
|
||||
], completer: completer),
|
||||
@ -313,7 +313,7 @@ void main() {
|
||||
trackWidgetCreation: false,
|
||||
dartDefines: const <String>['FOO=bar', 'BAZ=qux'],
|
||||
packageConfig: PackageConfig.empty,
|
||||
packagesPath: '.packages',
|
||||
packagesPath: '.dart_tool/package_config.json',
|
||||
);
|
||||
|
||||
stdoutHandler.compilerOutput?.complete(const CompilerOutput('', 0, <Uri>[]));
|
||||
@ -348,7 +348,7 @@ void main() {
|
||||
'--enable-asserts',
|
||||
'--no-link-platform',
|
||||
'--packages',
|
||||
'.packages',
|
||||
'.dart_tool/package_config.json',
|
||||
'--verbosity=error',
|
||||
'scheme:///main.dart',
|
||||
], completer: completer),
|
||||
@ -362,7 +362,7 @@ void main() {
|
||||
trackWidgetCreation: false,
|
||||
dartDefines: const <String>[],
|
||||
packageConfig: PackageConfig.empty,
|
||||
packagesPath: '.packages',
|
||||
packagesPath: '.dart_tool/package_config.json',
|
||||
);
|
||||
|
||||
stdoutHandler.compilerOutput?.complete(const CompilerOutput('', 0, <Uri>[]));
|
||||
@ -397,7 +397,7 @@ void main() {
|
||||
'--enable-asserts',
|
||||
'--no-link-platform',
|
||||
'--packages',
|
||||
'.packages',
|
||||
'.dart_tool/package_config.json',
|
||||
'--source',
|
||||
'.dart_tools/flutter_build/dart_plugin_registrant.dart',
|
||||
'--source',
|
||||
@ -422,7 +422,7 @@ void main() {
|
||||
trackWidgetCreation: false,
|
||||
dartDefines: const <String>[],
|
||||
packageConfig: PackageConfig.empty,
|
||||
packagesPath: '.packages',
|
||||
packagesPath: '.dart_tool/package_config.json',
|
||||
buildDir: buildDir,
|
||||
checkDartPluginRegistry: true,
|
||||
);
|
||||
@ -456,7 +456,7 @@ void main() {
|
||||
'--enable-asserts',
|
||||
'--no-link-platform',
|
||||
'--packages',
|
||||
'.packages',
|
||||
'.dart_tool/package_config.json',
|
||||
'--native-assets',
|
||||
'path/to/native_assets.yaml',
|
||||
'--verbosity=error',
|
||||
@ -472,7 +472,7 @@ void main() {
|
||||
trackWidgetCreation: false,
|
||||
dartDefines: const <String>[],
|
||||
packageConfig: PackageConfig.empty,
|
||||
packagesPath: '.packages',
|
||||
packagesPath: '.dart_tool/package_config.json',
|
||||
nativeAssets: 'path/to/native_assets.yaml',
|
||||
);
|
||||
stdoutHandler.compilerOutput
|
||||
|
@ -297,7 +297,10 @@ void main() {
|
||||
testWithoutContext('CustomDevice.isSupportedForProject is true with editable host app', () async {
|
||||
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').createSync();
|
||||
fileSystem
|
||||
.directory('.dart_tool')
|
||||
.childFile('package_config.json')
|
||||
.createSync(recursive: true);
|
||||
|
||||
final FlutterProject flutterProject = _setUpFlutterProject(fileSystem.currentDirectory);
|
||||
|
||||
|
@ -132,9 +132,14 @@ void main() {
|
||||
});
|
||||
|
||||
testUsingContext('setupHotRestart function fails', () async {
|
||||
fileSystem.file('.packages')
|
||||
fileSystem.directory('.dart_tool').childFile('package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('\n');
|
||||
..writeAsStringSync('''
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": []
|
||||
}
|
||||
''');
|
||||
final FakeDevice device = FakeDevice();
|
||||
final List<FlutterDevice> devices = <FlutterDevice>[
|
||||
FakeFlutterDevice(device),
|
||||
@ -158,9 +163,14 @@ void main() {
|
||||
});
|
||||
|
||||
testUsingContext('setupHotReload function fails', () async {
|
||||
fileSystem.file('.packages')
|
||||
fileSystem.directory('.dart_tool').childFile('package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('\n');
|
||||
..writeAsStringSync('''
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": []
|
||||
}
|
||||
''');
|
||||
final FakeDevice device = FakeDevice();
|
||||
final FakeFlutterDevice fakeFlutterDevice = FakeFlutterDevice(device);
|
||||
final List<FlutterDevice> devices = <FlutterDevice>[
|
||||
@ -203,9 +213,14 @@ void main() {
|
||||
});
|
||||
|
||||
testUsingContext('shutdown hook called after signal', () async {
|
||||
fileSystem.file('.packages')
|
||||
fileSystem.directory('.dart_tool').childFile('package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('\n');
|
||||
..writeAsStringSync('''
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": []
|
||||
}
|
||||
''');
|
||||
final FakeDevice device = FakeDevice();
|
||||
final List<FlutterDevice> devices = <FlutterDevice>[
|
||||
FlutterDevice(device, generator: residentCompiler, buildInfo: BuildInfo.debug, developmentShaderCompiler: const FakeShaderCompiler()),
|
||||
@ -226,9 +241,14 @@ void main() {
|
||||
});
|
||||
|
||||
testUsingContext('shutdown hook called after app stop', () async {
|
||||
fileSystem.file('.packages')
|
||||
fileSystem.directory('.dart_tool').childFile('package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('\n');
|
||||
..writeAsStringSync('''
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": []
|
||||
}
|
||||
''');
|
||||
final FakeDevice device = FakeDevice();
|
||||
final List<FlutterDevice> devices = <FlutterDevice>[
|
||||
FlutterDevice(device, generator: residentCompiler, buildInfo: BuildInfo.debug, developmentShaderCompiler: const FakeShaderCompiler()),
|
||||
@ -545,9 +565,14 @@ void main() {
|
||||
|
||||
testUsingContext('Exits with code 2 when HttpException is thrown '
|
||||
'during VM service connection', () async {
|
||||
fileSystem.file('.packages')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('\n');
|
||||
fileSystem.directory('.dart_tool').childFile('package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": []
|
||||
}
|
||||
''');
|
||||
|
||||
final FakeResidentCompiler residentCompiler = FakeResidentCompiler();
|
||||
final FakeDevice device = FakeDevice();
|
||||
|
@ -39,7 +39,6 @@ name: example
|
||||
flutter:
|
||||
module: {}
|
||||
''');
|
||||
fileSystem.file('.packages').writeAsStringSync('\n');
|
||||
final FlutterProject flutterProject =
|
||||
FlutterProject.fromDirectory(fileSystem.currentDirectory);
|
||||
final IOSDevice device = setUpIOSDevice(fileSystem);
|
||||
@ -53,7 +52,6 @@ flutter:
|
||||
testUsingContext('IOSDevice.isSupportedForProject is true with editable host app', () async {
|
||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').writeAsStringSync('\n');
|
||||
fileSystem.directory('ios').createSync();
|
||||
final FlutterProject flutterProject =
|
||||
FlutterProject.fromDirectory(fileSystem.currentDirectory);
|
||||
@ -69,7 +67,6 @@ flutter:
|
||||
testUsingContext('IOSDevice.isSupportedForProject is false with no host app and no module', () async {
|
||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').writeAsStringSync('\n');
|
||||
final FlutterProject flutterProject =
|
||||
FlutterProject.fromDirectory(fileSystem.currentDirectory);
|
||||
final IOSDevice device = setUpIOSDevice(fileSystem);
|
||||
|
@ -114,9 +114,6 @@ void main() {
|
||||
);
|
||||
fakeXcodeProjectInterpreter = FakeXcodeProjectInterpreter(projectInfo: projectInfo);
|
||||
xcode = Xcode.test(processManager: FakeProcessManager.any(), xcodeProjectInterpreter: fakeXcodeProjectInterpreter);
|
||||
fileSystem.file('foo/.packages')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('\n');
|
||||
fakeAnalytics = getInitializedFakeAnalyticsInstance(
|
||||
fs: fileSystem,
|
||||
fakeFlutterVersion: FakeFlutterVersion(),
|
||||
@ -421,9 +418,6 @@ void main() {
|
||||
);
|
||||
fakeXcodeProjectInterpreter = FakeXcodeProjectInterpreter(projectInfo: projectInfo);
|
||||
xcode = Xcode.test(processManager: FakeProcessManager.any(), xcodeProjectInterpreter: fakeXcodeProjectInterpreter);
|
||||
fileSystem.file('foo/.packages')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('\n');
|
||||
});
|
||||
|
||||
group('in release mode', () {
|
||||
@ -920,7 +914,10 @@ void main() {
|
||||
|
||||
void setUpIOSProject(FileSystem fileSystem, {bool createWorkspace = true}) {
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').writeAsStringSync('\n');
|
||||
fileSystem
|
||||
.directory('.dart_tool')
|
||||
.childFile('package_config.json')
|
||||
.createSync(recursive: true);
|
||||
fileSystem.directory('ios').createSync();
|
||||
if (createWorkspace) {
|
||||
fileSystem.directory('ios/Runner.xcworkspace').createSync();
|
||||
|
@ -645,7 +645,6 @@ duplicate symbol '_$s29plugin_1_name23PluginNamePluginC9setDouble3key5valueySS_S
|
||||
final MemoryFileSystem fs = MemoryFileSystem.test();
|
||||
final FakeFlutterProject project = FakeFlutterProject(fileSystem: fs);
|
||||
project.ios.podfile.createSync(recursive: true);
|
||||
project.directory.childFile('.packages').createSync(recursive: true);
|
||||
project.manifest = FakeFlutterManifest();
|
||||
createFakePlugins(project, fs, <String>['plugin_1_name', 'plugin_2_name']);
|
||||
fs.systemTempDirectory.childFile('cache/plugin_1_name/ios/plugin_1_name/Package.swift')
|
||||
|
@ -1292,7 +1292,6 @@ name: example
|
||||
flutter:
|
||||
module: {}
|
||||
''');
|
||||
globals.fs.file('.packages').createSync();
|
||||
final FlutterProject flutterProject = FlutterProject.fromDirectoryTest(globals.fs.currentDirectory);
|
||||
|
||||
final IOSSimulator simulator = IOSSimulator(
|
||||
@ -1312,7 +1311,6 @@ flutter:
|
||||
|
||||
testUsingContext('is true with editable host app', () async {
|
||||
globals.fs.file('pubspec.yaml').createSync();
|
||||
globals.fs.file('.packages').createSync();
|
||||
globals.fs.directory('ios').createSync();
|
||||
final FlutterProject flutterProject = FlutterProject.fromDirectoryTest(globals.fs.currentDirectory);
|
||||
|
||||
@ -1332,7 +1330,6 @@ flutter:
|
||||
|
||||
testUsingContext('is false with no host app and no module', () async {
|
||||
globals.fs.file('pubspec.yaml').createSync();
|
||||
globals.fs.file('.packages').createSync();
|
||||
final FlutterProject flutterProject = FlutterProject.fromDirectoryTest(globals.fs.currentDirectory);
|
||||
|
||||
final IOSSimulator simulator = IOSSimulator(
|
||||
|
@ -26,8 +26,6 @@ void main() {
|
||||
|
||||
setUp(() {
|
||||
testbed = Testbed(setup: () {
|
||||
globals.fs.file('.packages')
|
||||
.writeAsStringSync('\n');
|
||||
globals.fs.file(globals.fs.path.join('build', 'app.dill'))
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('ABC');
|
||||
|
@ -119,7 +119,6 @@ void main() {
|
||||
testWithoutContext('LinuxDevice.isSupportedForProject is true with editable host app', () async {
|
||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').createSync();
|
||||
fileSystem.directory('linux').createSync();
|
||||
final FlutterProject flutterProject = setUpFlutterProject(fileSystem.currentDirectory);
|
||||
|
||||
@ -134,7 +133,6 @@ void main() {
|
||||
testWithoutContext('LinuxDevice.isSupportedForProject is false with no host app', () async {
|
||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').createSync();
|
||||
final FlutterProject flutterProject = setUpFlutterProject(fileSystem.currentDirectory);
|
||||
|
||||
expect(LinuxDevice(
|
||||
|
@ -173,7 +173,6 @@ void main() {
|
||||
);
|
||||
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').createSync();
|
||||
fileSystem.directory('macos').createSync();
|
||||
final FlutterProject flutterProject = setUpFlutterProject(fileSystem.currentDirectory);
|
||||
|
||||
@ -217,7 +216,6 @@ void main() {
|
||||
operatingSystemUtils: FakeOperatingSystemUtils(),
|
||||
);
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').createSync();
|
||||
final FlutterProject flutterProject = setUpFlutterProject(fileSystem.currentDirectory);
|
||||
|
||||
expect(device.isSupportedForProject(flutterProject), false);
|
||||
|
@ -1863,7 +1863,7 @@ The Flutter Preview device does not support the following plugins from your pubs
|
||||
..flutterPluginsDependenciesFile = dependenciesFile
|
||||
..windows = windowsProject;
|
||||
|
||||
flutterProject.directory.childFile('.packages').createSync(recursive: true);
|
||||
flutterProject.directory.childDirectory('.dart_tool').childFile('package_config.json').createSync(recursive: true);
|
||||
|
||||
const String dependenciesFileContents = r'''
|
||||
{
|
||||
@ -1993,7 +1993,7 @@ The Flutter Preview device does not support the following plugins from your pubs
|
||||
flutterProject.directory.childFile('.flutter-plugins-dependencies')
|
||||
..windows = windowsProject;
|
||||
|
||||
flutterProject.directory.childFile('.packages').createSync(recursive: true);
|
||||
flutterProject.directory.childDirectory('.dart_tool').childFile('package_config.json').createSync(recursive: true);
|
||||
|
||||
createPluginSymlinks(
|
||||
flutterProject,
|
||||
|
@ -51,8 +51,6 @@ void main() {
|
||||
|
||||
setUp(() {
|
||||
testbed = Testbed(setup: () {
|
||||
globals.fs.file('.packages')
|
||||
.writeAsStringSync('\n');
|
||||
globals.fs.file(globals.fs.path.join('build', 'app.dill'))
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('ABC');
|
||||
@ -1172,9 +1170,6 @@ dependencies:
|
||||
}
|
||||
]
|
||||
}
|
||||
''');
|
||||
globals.fs.file('.packages').writeAsStringSync('''
|
||||
path_provider_linux:/path_provider_linux/lib/
|
||||
''');
|
||||
final Directory fakePluginDir = globals.fs.directory('path_provider_linux');
|
||||
final File pluginPubspec = fakePluginDir.childFile('pubspec.yaml');
|
||||
|
@ -38,7 +38,10 @@ void main() {
|
||||
mockFlutterDevice = FakeFlutterDevice(mockWebDevice);
|
||||
mockFlutterDevice._devFS = mockWebDevFS;
|
||||
|
||||
fileSystem.file('.packages').writeAsStringSync('\n');
|
||||
fileSystem
|
||||
.directory('.dart_tool')
|
||||
.childFile('package_config.json')
|
||||
.createSync(recursive: true);
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||
fileSystem.file(fileSystem.path.join('web', 'index.html')).createSync(recursive: true);
|
||||
|
@ -127,7 +127,10 @@ void main() {
|
||||
.._devFS = webDevFS
|
||||
..device = mockDevice
|
||||
..generator = residentCompiler;
|
||||
fileSystem.file('.packages').writeAsStringSync('\n');
|
||||
fileSystem
|
||||
.directory('.dart_tool')
|
||||
.childFile('package_config.json')
|
||||
.createSync(recursive: true);
|
||||
fakeAnalytics = getInitializedFakeAnalyticsInstance(
|
||||
fs: fileSystem,
|
||||
fakeFlutterVersion: test_fakes.FakeFlutterVersion(),
|
||||
|
@ -213,9 +213,9 @@ void main() {
|
||||
testUsingContext("Doesn't crash on invalid .packages file", () async {
|
||||
final FlutterCommandRunner runner = createTestCommandRunner(DummyFlutterCommand()) as FlutterCommandRunner;
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages')
|
||||
..createSync()
|
||||
..writeAsStringSync('Not a valid package');
|
||||
fileSystem.directory('.dart_tool').childFile('package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('Not a valid package config');
|
||||
|
||||
await runner.run(<String>['dummy']);
|
||||
|
||||
|
@ -814,7 +814,6 @@ void main() {
|
||||
testUsingContext('parses values from JSON files and includes them in defines list', () async {
|
||||
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').createSync();
|
||||
await fileSystem.file('config1.json').writeAsString(
|
||||
'''
|
||||
{
|
||||
@ -864,7 +863,6 @@ void main() {
|
||||
.file(fileSystem.path.join('lib', 'main.dart'))
|
||||
.createSync(recursive: true);
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').createSync();
|
||||
fileSystem.file('.env').writeAsStringSync('''
|
||||
MY_VALUE=VALUE_FROM_ENV_FILE
|
||||
''');
|
||||
@ -893,7 +891,6 @@ void main() {
|
||||
.file(fileSystem.path.join('lib', 'main.dart'))
|
||||
.createSync(recursive: true);
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').createSync();
|
||||
await fileSystem.file('.env').writeAsString('''
|
||||
# comment
|
||||
kInt=1
|
||||
@ -956,7 +953,6 @@ void main() {
|
||||
.file(fileSystem.path.join('lib', 'main.dart'))
|
||||
.createSync(recursive: true);
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').createSync();
|
||||
await fileSystem.file('.env').writeAsString('what is this');
|
||||
|
||||
await dummyCommandRunner.run(<String>[
|
||||
@ -982,7 +978,6 @@ void main() {
|
||||
.file(fileSystem.path.join('lib', 'main.dart'))
|
||||
.createSync(recursive: true);
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').createSync();
|
||||
await fileSystem.file('.env').writeAsString('''
|
||||
# single line value
|
||||
name=piotrfleury
|
||||
@ -1015,7 +1010,6 @@ void main() {
|
||||
.file(fileSystem.path.join('lib', 'main.dart'))
|
||||
.createSync(recursive: true);
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').createSync();
|
||||
await fileSystem.file('.env').writeAsString('''
|
||||
kInt=1
|
||||
kDouble=1.1
|
||||
@ -1053,7 +1047,6 @@ void main() {
|
||||
testUsingContext('when files contain entries with duplicate keys, uses the value from the lattermost file', () async {
|
||||
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').createSync();
|
||||
await fileSystem.file('config1.json').writeAsString(
|
||||
'''
|
||||
{
|
||||
@ -1095,7 +1088,6 @@ void main() {
|
||||
testUsingContext('throws a ToolExit when the argued path points to a directory', () async {
|
||||
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').createSync();
|
||||
fileSystem.directory('config').createSync();
|
||||
|
||||
await dummyCommandRunner.run(<String>[
|
||||
@ -1115,7 +1107,6 @@ void main() {
|
||||
testUsingContext('throws a ToolExit when the given JSON file is malformed', () async {
|
||||
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').createSync();
|
||||
await fileSystem.file('config.json').writeAsString(
|
||||
'''
|
||||
{
|
||||
@ -1174,7 +1165,6 @@ void main() {
|
||||
testUsingContext("tool exits when FLUTTER_APP_FLAVOR is already set in user's environment", () async {
|
||||
fileSystem.file('lib/main.dart').createSync(recursive: true);
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').createSync();
|
||||
|
||||
final FakeDevice device = FakeDevice(
|
||||
'name',
|
||||
@ -1204,7 +1194,6 @@ void main() {
|
||||
testUsingContext('tool exits when FLUTTER_APP_FLAVOR is set in --dart-define or --dart-define-from-file', () async {
|
||||
fileSystem.file('lib/main.dart').createSync(recursive: true);
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').createSync();
|
||||
fileSystem.file('config.json')..createSync()..writeAsStringSync('{"FLUTTER_APP_FLAVOR": "strawberry"}');
|
||||
|
||||
final FakeDevice device = FakeDevice(
|
||||
|
@ -14,7 +14,7 @@ import '../../src/common.dart';
|
||||
|
||||
const String kEngineRoot = '/flutter/engine';
|
||||
const String kArbitraryEngineRoot = '/arbitrary/engine';
|
||||
const String kDotPackages = '.packages';
|
||||
const String kPackageConfig = '.dart_tool/package_config.json';
|
||||
|
||||
void main() {
|
||||
testWithoutContext('works if --local-engine is specified and --local-engine-src-path '
|
||||
@ -27,8 +27,20 @@ void main() {
|
||||
.directory('$kArbitraryEngineRoot/src/out/host_debug')
|
||||
.createSync(recursive: true);
|
||||
fileSystem
|
||||
.file(kDotPackages)
|
||||
.writeAsStringSync('sky_engine:file://$kArbitraryEngineRoot/src/out/ios_debug/gen/dart-pkg/sky_engine/lib/');
|
||||
.file(kPackageConfig)
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": [
|
||||
{
|
||||
"name": "sky_engine",
|
||||
"rootUri": "file://$kArbitraryEngineRoot/src/out/ios_debug/gen/dart-pkg/sky_engine",
|
||||
"packageUri": "lib/"
|
||||
}
|
||||
]
|
||||
}
|
||||
''');
|
||||
fileSystem
|
||||
.file('bin/cache/pkg/sky_engine/lib')
|
||||
.createSync(recursive: true);
|
||||
@ -54,8 +66,20 @@ void main() {
|
||||
// Verify that this also works if the sky_engine path is a symlink to the engine root.
|
||||
fileSystem.link('/symlink').createSync(kArbitraryEngineRoot);
|
||||
fileSystem
|
||||
.file(kDotPackages)
|
||||
.writeAsStringSync('sky_engine:file:///symlink/src/out/ios_debug/gen/dart-pkg/sky_engine/lib/');
|
||||
.file(kPackageConfig)
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": [
|
||||
{
|
||||
"name": "sky_engine",
|
||||
"rootUri": "file:///symlink/src/out/ios_debug/gen/dart-pkg/sky_engine/",
|
||||
"packageUri": "lib/"
|
||||
}
|
||||
]
|
||||
}
|
||||
''');
|
||||
|
||||
expect(
|
||||
await localEngineLocator.findEnginePath(localEngine: 'ios_debug', localHostEngine: 'host_debug'),
|
||||
@ -296,7 +320,9 @@ void main() {
|
||||
testWithoutContext('works if --local-engine is specified and --local-engine-src-path '
|
||||
'is determined by flutter root', () async {
|
||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||
fileSystem.file(kDotPackages).writeAsStringSync('\n');
|
||||
fileSystem
|
||||
.file(kPackageConfig)
|
||||
.createSync(recursive: true);
|
||||
fileSystem
|
||||
.directory('$kEngineRoot/src/out/ios_debug')
|
||||
.createSync(recursive: true);
|
||||
|
@ -42,7 +42,10 @@ void main() {
|
||||
fileSystem = MemoryFileSystem.test();
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('test/foo.dart').createSync(recursive: true);
|
||||
fileSystem.file('.packages').createSync();
|
||||
fileSystem
|
||||
.directory('.dart_tool')
|
||||
.childFile('package_config.json')
|
||||
.createSync(recursive: true);
|
||||
residentCompiler = FakeResidentCompiler(fileSystem);
|
||||
logger = LoggingLogger();
|
||||
});
|
||||
@ -155,7 +158,22 @@ dependencies:
|
||||
sdk: flutter
|
||||
a_plugin: 1.0.0
|
||||
''');
|
||||
fileSystem.file('.packages').writeAsStringSync('a_plugin:/a_plugin/lib/');
|
||||
fileSystem
|
||||
.directory('.dart_tool')
|
||||
.childFile('package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": [
|
||||
{
|
||||
"name": "a_plugin",
|
||||
"rootUri": "/a_plugin/",
|
||||
"packageUri": "lib/"
|
||||
}
|
||||
]
|
||||
}
|
||||
''');
|
||||
fakeDartPlugin.childFile('pubspec.yaml')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
|
@ -37,7 +37,11 @@ void main() {
|
||||
);
|
||||
|
||||
flutterProject = FlutterProject.fromDirectoryTest(fileSystem.currentDirectory);
|
||||
fileSystem.file('.packages').createSync();
|
||||
|
||||
fileSystem
|
||||
.directory('.dart_tool')
|
||||
.childFile('package_config.json')
|
||||
.createSync(recursive: true);
|
||||
});
|
||||
|
||||
testUsingContext('WebBuilder sets environment on success', () async {
|
||||
|
@ -909,7 +909,7 @@ void main() {
|
||||
port: 0,
|
||||
tlsCertPath: null,
|
||||
tlsCertKeyPath: null,
|
||||
packagesFilePath: '.packages',
|
||||
packagesFilePath: '.dart_tool/package_config.json',
|
||||
urlTunneller: null, // ignore: avoid_redundant_argument_values
|
||||
useSseForDebugProxy: true,
|
||||
useSseForDebugBackend: true,
|
||||
@ -1049,7 +1049,7 @@ void main() {
|
||||
port: 0,
|
||||
tlsCertPath: null,
|
||||
tlsCertKeyPath: null,
|
||||
packagesFilePath: '.packages',
|
||||
packagesFilePath: '.dart_tool/package_config.json',
|
||||
urlTunneller: null, // ignore: avoid_redundant_argument_values
|
||||
useSseForDebugProxy: true,
|
||||
useSseForDebugBackend: true,
|
||||
@ -1189,7 +1189,7 @@ void main() {
|
||||
port: 0,
|
||||
tlsCertPath: null,
|
||||
tlsCertKeyPath: null,
|
||||
packagesFilePath: '.packages',
|
||||
packagesFilePath: '.dart_tool/package_config.json',
|
||||
urlTunneller: null,
|
||||
useSseForDebugProxy: true,
|
||||
useSseForDebugBackend: true,
|
||||
@ -1268,7 +1268,7 @@ void main() {
|
||||
port: 0,
|
||||
tlsCertPath: null,
|
||||
tlsCertKeyPath: null,
|
||||
packagesFilePath: '.packages',
|
||||
packagesFilePath: '.dart_tool/package_config.json',
|
||||
urlTunneller: null, // ignore: avoid_redundant_argument_values
|
||||
useSseForDebugProxy: true,
|
||||
useSseForDebugBackend: true,
|
||||
@ -1315,7 +1315,7 @@ void main() {
|
||||
port: 0,
|
||||
tlsCertPath: null,
|
||||
tlsCertKeyPath: null,
|
||||
packagesFilePath: '.packages',
|
||||
packagesFilePath: '.dart_tool/package_config.json',
|
||||
urlTunneller: null, // ignore: avoid_redundant_argument_values
|
||||
useSseForDebugProxy: true,
|
||||
useSseForDebugBackend: true,
|
||||
@ -1371,7 +1371,7 @@ void main() {
|
||||
port: 0,
|
||||
tlsCertPath: null,
|
||||
tlsCertKeyPath: null,
|
||||
packagesFilePath: '.packages',
|
||||
packagesFilePath: '.dart_tool/package_config.json',
|
||||
urlTunneller: null, // ignore: avoid_redundant_argument_values
|
||||
useSseForDebugProxy: true,
|
||||
useSseForDebugBackend: true,
|
||||
@ -1433,7 +1433,7 @@ void main() {
|
||||
port: 0,
|
||||
tlsCertPath: dummyCertPath,
|
||||
tlsCertKeyPath: dummyCertKeyPath,
|
||||
packagesFilePath: '.packages',
|
||||
packagesFilePath: '.dart_tool/package_config.json',
|
||||
urlTunneller: null, // ignore: avoid_redundant_argument_values
|
||||
useSseForDebugProxy: true,
|
||||
useSseForDebugBackend: true,
|
||||
@ -1613,7 +1613,7 @@ void main() {
|
||||
port: 0,
|
||||
tlsCertPath: null,
|
||||
tlsCertKeyPath: null,
|
||||
packagesFilePath: '.packages',
|
||||
packagesFilePath: '.dart_tool/package_config.json',
|
||||
urlTunneller: null, // ignore: avoid_redundant_argument_values
|
||||
useSseForDebugProxy: true,
|
||||
useSseForDebugBackend: true,
|
||||
|
@ -740,7 +740,7 @@ void main() {
|
||||
port: 0,
|
||||
tlsCertPath: null,
|
||||
tlsCertKeyPath: null,
|
||||
packagesFilePath: '.packages',
|
||||
packagesFilePath: '.dart_tool/package_config.json',
|
||||
urlTunneller: null,
|
||||
useSseForDebugProxy: true,
|
||||
useSseForDebugBackend: true,
|
||||
@ -856,7 +856,7 @@ void main() {
|
||||
port: 0,
|
||||
tlsCertPath: null,
|
||||
tlsCertKeyPath: null,
|
||||
packagesFilePath: '.packages',
|
||||
packagesFilePath: '.dart_tool/package_config.json',
|
||||
urlTunneller: null,
|
||||
useSseForDebugProxy: true,
|
||||
useSseForDebugBackend: true,
|
||||
@ -977,7 +977,7 @@ void main() {
|
||||
port: 0,
|
||||
tlsCertPath: null,
|
||||
tlsCertKeyPath: null,
|
||||
packagesFilePath: '.packages',
|
||||
packagesFilePath: '.dart_tool/package_config.json',
|
||||
urlTunneller: null,
|
||||
useSseForDebugProxy: true,
|
||||
useSseForDebugBackend: true,
|
||||
@ -1048,7 +1048,7 @@ void main() {
|
||||
port: 0,
|
||||
tlsCertPath: null,
|
||||
tlsCertKeyPath: null,
|
||||
packagesFilePath: '.packages',
|
||||
packagesFilePath: '.dart_tool/package_config.json',
|
||||
urlTunneller: null,
|
||||
useSseForDebugProxy: true,
|
||||
useSseForDebugBackend: true,
|
||||
@ -1091,7 +1091,7 @@ void main() {
|
||||
port: 0,
|
||||
tlsCertPath: null,
|
||||
tlsCertKeyPath: null,
|
||||
packagesFilePath: '.packages',
|
||||
packagesFilePath: '.dart_tool/package_config.json',
|
||||
urlTunneller: null,
|
||||
useSseForDebugProxy: true,
|
||||
useSseForDebugBackend: true,
|
||||
@ -1143,7 +1143,7 @@ void main() {
|
||||
port: 0,
|
||||
tlsCertPath: null,
|
||||
tlsCertKeyPath: null,
|
||||
packagesFilePath: '.packages',
|
||||
packagesFilePath: '.dart_tool/package_config.json',
|
||||
urlTunneller: null,
|
||||
useSseForDebugProxy: true,
|
||||
useSseForDebugBackend: true,
|
||||
@ -1203,7 +1203,7 @@ void main() {
|
||||
port: 0,
|
||||
tlsCertPath: dummyCertPath,
|
||||
tlsCertKeyPath: dummyCertKeyPath,
|
||||
packagesFilePath: '.packages',
|
||||
packagesFilePath: '.dart_tool/package_config.json',
|
||||
urlTunneller: null,
|
||||
useSseForDebugProxy: true,
|
||||
useSseForDebugBackend: true,
|
||||
@ -1366,7 +1366,7 @@ void main() {
|
||||
port: 0,
|
||||
tlsCertPath: null,
|
||||
tlsCertKeyPath: null,
|
||||
packagesFilePath: '.packages',
|
||||
packagesFilePath: '.dart_tool/package_config.json',
|
||||
urlTunneller: null,
|
||||
useSseForDebugProxy: true,
|
||||
useSseForDebugBackend: true,
|
||||
|
@ -200,7 +200,7 @@ void writeGeneratedPluginRegistrant(FileSystem fs) {
|
||||
// (taken from commands.shard/hermetic/build_web_test.dart)
|
||||
void setupFileSystemForEndToEndTest(FileSystem fileSystem) {
|
||||
final List<String> dependencies = <String>[
|
||||
'.packages',
|
||||
fileSystem.path.join('.dart_tool', 'package_config.json'),
|
||||
fileSystem.path.join('web', 'index.html'),
|
||||
fileSystem.path.join('lib', 'main.dart'),
|
||||
fileSystem.path.join('packages', 'flutter_tools', 'lib', 'src', 'build_system', 'targets', 'web.dart'),
|
||||
@ -214,11 +214,6 @@ void setupFileSystemForEndToEndTest(FileSystem fileSystem) {
|
||||
}
|
||||
|
||||
// Project files.
|
||||
fileSystem.file('.packages')
|
||||
.writeAsStringSync('''
|
||||
foo:lib/
|
||||
fizz:bar/lib/
|
||||
''');
|
||||
fileSystem.file('pubspec.yaml')
|
||||
.writeAsStringSync('''
|
||||
name: foo
|
||||
|
@ -68,7 +68,6 @@ void main() {
|
||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||
final WindowsDevice windowsDevice = setUpWindowsDevice(fileSystem: fileSystem);
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').createSync();
|
||||
fileSystem.directory('windows').createSync();
|
||||
fileSystem.file(fileSystem.path.join('windows', 'CMakeLists.txt')).createSync();
|
||||
final FlutterProject flutterProject = setUpFlutterProject(fileSystem.currentDirectory);
|
||||
@ -80,7 +79,6 @@ void main() {
|
||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||
final WindowsDevice windowsDevice = setUpWindowsDevice(fileSystem: fileSystem);
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').createSync();
|
||||
final FlutterProject flutterProject = setUpFlutterProject(fileSystem.currentDirectory);
|
||||
|
||||
expect(windowsDevice.isSupportedForProject(flutterProject), false);
|
||||
@ -90,7 +88,6 @@ void main() {
|
||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||
final WindowsDevice windowsDevice = setUpWindowsDevice(fileSystem: fileSystem);
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').createSync();
|
||||
fileSystem.directory('windows').createSync();
|
||||
final FlutterProject flutterProject = setUpFlutterProject(fileSystem.currentDirectory);
|
||||
|
||||
|
@ -95,9 +95,6 @@ void main() {
|
||||
directory
|
||||
.childFile('pubspec.yaml')
|
||||
.writeAsStringSync('name: foo');
|
||||
directory
|
||||
.childFile('.packages')
|
||||
.writeAsStringSync('\n');
|
||||
directory
|
||||
.childDirectory('lib')
|
||||
.childFile('main.dart')
|
||||
|
@ -62,7 +62,7 @@ abstract class Project {
|
||||
writeFile(fileSystem.path.join(dir.path, 'web', 'index.html'), indexHtml);
|
||||
writeFile(fileSystem.path.join(dir.path, 'web', 'flutter.js'), '');
|
||||
writeFile(fileSystem.path.join(dir.path, 'web', 'flutter_service_worker.js'), '');
|
||||
writePackages(dir.path);
|
||||
writePackageConfig(dir.path);
|
||||
await getPackages(dir.path);
|
||||
}
|
||||
|
||||
|
@ -48,9 +48,18 @@ void writeBytesFile(String path, List<int> content) {
|
||||
..writeAsBytesSync(content, flush: true);
|
||||
}
|
||||
|
||||
void writePackages(String folder) {
|
||||
writeFile(fileSystem.path.join(folder, '.packages'), '''
|
||||
test:${fileSystem.path.join(fileSystem.currentDirectory.path, 'lib')}/
|
||||
void writePackageConfig(String folder) {
|
||||
writeFile(fileSystem.path.join(folder, '.dart_tool', 'package_config.json'), '''
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": [
|
||||
{
|
||||
"name": "test",
|
||||
"rootUri": "fileSystem.currentDirectory.path"
|
||||
"packageUri": "lib/",
|
||||
}
|
||||
]
|
||||
}
|
||||
''');
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user