Fix a bug to skip flutter_gen
when synthetic packages are disabled (#160367)
Without this bug fix, when flipping the flag a lot of things blow up :) (https://github.com/flutter/flutter/pull/160289 as an example of needing this)
This commit is contained in:
parent
1c52436853
commit
daaceacb30
@ -49,7 +49,7 @@ Future<void> generateLocalizationsSyntheticPackage({
|
|||||||
// Generate gen_l10n synthetic package only if synthetic-package: true or
|
// Generate gen_l10n synthetic package only if synthetic-package: true or
|
||||||
// synthetic-package is null.
|
// synthetic-package is null.
|
||||||
final bool? isSyntheticL10nPackage = value as bool?;
|
final bool? isSyntheticL10nPackage = value as bool?;
|
||||||
if (isSyntheticL10nPackage == false) {
|
if (isSyntheticL10nPackage == false || isSyntheticL10nPackage == null && featureFlags.isExplicitPackageDependenciesEnabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (featureFlags.isExplicitPackageDependenciesEnabled) {
|
} else if (featureFlags.isExplicitPackageDependenciesEnabled) {
|
||||||
|
@ -28,6 +28,14 @@ void main() {
|
|||||||
return TestFeatureFlags(isExplicitPackageDependenciesEnabled: false);
|
return TestFeatureFlags(isExplicitPackageDependenciesEnabled: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(matanlurey): Remove after `explicit-package-dependencies` is enabled by default.
|
||||||
|
// See https://github.com/flutter/flutter/issues/160257 for details.
|
||||||
|
FeatureFlags enableExplicitPackageDependencies() {
|
||||||
|
return TestFeatureFlags(
|
||||||
|
isExplicitPackageDependenciesEnabled: true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
testUsingContext('calls buildSystem.build with blank l10n.yaml file', () async {
|
testUsingContext('calls buildSystem.build with blank l10n.yaml file', () async {
|
||||||
// Project directory setup for gen_l10n logic
|
// Project directory setup for gen_l10n logic
|
||||||
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
|
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
|
||||||
@ -394,6 +402,42 @@ void main() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testUsingContext('synthetic-package omitted with explicit-package-dependencies is a NOP', () async {
|
||||||
|
// Project directory setup for gen_l10n logic
|
||||||
|
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
|
||||||
|
|
||||||
|
// Add generate:true to pubspec.yaml.
|
||||||
|
final File pubspecFile = fileSystem.file('pubspec.yaml')..createSync();
|
||||||
|
final String content = pubspecFile.readAsStringSync().replaceFirst(
|
||||||
|
'\nflutter:\n',
|
||||||
|
'\nflutter:\n generate: true\n',
|
||||||
|
);
|
||||||
|
pubspecFile.writeAsStringSync(content);
|
||||||
|
|
||||||
|
final BufferLogger mockBufferLogger = BufferLogger.test();
|
||||||
|
final Environment environment = Environment.test(
|
||||||
|
fileSystem.currentDirectory,
|
||||||
|
fileSystem: fileSystem,
|
||||||
|
logger: mockBufferLogger,
|
||||||
|
artifacts: Artifacts.test(),
|
||||||
|
processManager: FakeProcessManager.empty(),
|
||||||
|
);
|
||||||
|
final TestBuildSystem buildSystem = TestBuildSystem.all(BuildResult(success: true));
|
||||||
|
|
||||||
|
await generateLocalizationsSyntheticPackage(
|
||||||
|
environment: environment,
|
||||||
|
buildSystem: buildSystem,
|
||||||
|
buildTargets: const NoOpBuildTargets(),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
mockBufferLogger.warningText,
|
||||||
|
isNot(contains('https://flutter.dev/to/flutter-gen-deprecation')),
|
||||||
|
);
|
||||||
|
}, overrides: <Type, Generator> {
|
||||||
|
FeatureFlags: enableExplicitPackageDependencies,
|
||||||
|
});
|
||||||
|
|
||||||
testUsingContext('synthetic-package: true with explicit-packages-resolution is an error', () async {
|
testUsingContext('synthetic-package: true with explicit-packages-resolution is an error', () async {
|
||||||
// Project directory setup for gen_l10n logic
|
// Project directory setup for gen_l10n logic
|
||||||
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
|
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user