Add .flutter-plugins-dependencies
to FlutterBuildSystem
; update logic, add tests. (#163278)
I happened to run into this while chasing other bugs, and noticed `.flutter-plugins-dependencies` is omitted. I am guessing this is probably quite stale, but something something [Chesterton's fence](https://en.wiktionary.org/wiki/Chesterton%27s_fence), and added tests.
This commit is contained in:
parent
7cf38fd93c
commit
441bb070fe
@ -639,15 +639,20 @@ class FlutterBuildSystem extends BuildSystem {
|
|||||||
// We also remove files under .dart_tool, since these are intermediaries
|
// We also remove files under .dart_tool, since these are intermediaries
|
||||||
// and don't need to be tracked by external systems.
|
// and don't need to be tracked by external systems.
|
||||||
{
|
{
|
||||||
|
bool isUnconditionalFile(String path) {
|
||||||
|
return switch (_fileSystem.path.basename(path)) {
|
||||||
|
'.flutter-plugins' || '.flutter-plugins-dependencies' => true,
|
||||||
|
_ when _fileSystem.path.extension(path) == '.xcconfig' => true,
|
||||||
|
_ when _fileSystem.path.split(path).contains('.dart_tool') => true,
|
||||||
|
_ => false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
buildInstance.inputFiles.removeWhere((String path, File file) {
|
buildInstance.inputFiles.removeWhere((String path, File file) {
|
||||||
return path.contains('.flutter-plugins') ||
|
return isUnconditionalFile(path);
|
||||||
path.contains('xcconfig') ||
|
|
||||||
path.contains('.dart_tool');
|
|
||||||
});
|
});
|
||||||
buildInstance.outputFiles.removeWhere((String path, File file) {
|
buildInstance.outputFiles.removeWhere((String path, File file) {
|
||||||
return path.contains('.flutter-plugins') ||
|
return isUnconditionalFile(path);
|
||||||
path.contains('xcconfig') ||
|
|
||||||
path.contains('.dart_tool');
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
trackSharedBuildDirectory(environment, _fileSystem, buildInstance.outputFiles);
|
trackSharedBuildDirectory(environment, _fileSystem, buildInstance.outputFiles);
|
||||||
|
@ -152,6 +152,79 @@ void main() {
|
|||||||
expect(result.outputFiles.single.path, '${environment.buildDir.path}/out');
|
expect(result.outputFiles.single.path, '${environment.buildDir.path}/out');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
group('BuildResult.outputs filtering', () {
|
||||||
|
final TestTarget allFilesTarget =
|
||||||
|
TestTarget((Environment environment) async {})
|
||||||
|
..name = 'allTextFiles'
|
||||||
|
..inputs = const <Source>[
|
||||||
|
Source.pattern('{PROJECT_DIR}/*'),
|
||||||
|
Source.pattern('{PROJECT_DIR}/*/*'),
|
||||||
|
]
|
||||||
|
..outputs = const <Source>[Source.pattern('{BUILD_DIR}/out')]
|
||||||
|
..dependencies = <Target>[];
|
||||||
|
late BuildSystem buildSystem;
|
||||||
|
|
||||||
|
setUp(() {
|
||||||
|
buildSystem = setUpBuildSystem(fileSystem);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWithoutContext('normally would update when something has changed', () async {
|
||||||
|
environment.projectDir.childFile('foo.dart').createSync();
|
||||||
|
final BuildResult result = await buildSystem.build(allFilesTarget, environment);
|
||||||
|
expect(
|
||||||
|
result.inputFiles,
|
||||||
|
contains(isA<File>().having((File f) => f.path, 'path', endsWith('foo.dart'))),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWithoutContext('ignores the .dart_tool directory', () async {
|
||||||
|
environment.projectDir.childDirectory('.dart_tool').createSync();
|
||||||
|
environment.projectDir.childDirectory('.dart_tool').childFile('IGNORE_ME.txt').createSync();
|
||||||
|
final BuildResult result = await buildSystem.build(allFilesTarget, environment);
|
||||||
|
expect(
|
||||||
|
result.inputFiles,
|
||||||
|
isNot(contains(isA<File>().having((File f) => f.path, 'path', endsWith('IGNORE_ME.txt')))),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWithoutContext('ignores files named .flutter-plugins', () async {
|
||||||
|
environment.projectDir.childFile('.flutter-plugins').createSync();
|
||||||
|
final BuildResult result = await buildSystem.build(allFilesTarget, environment);
|
||||||
|
expect(
|
||||||
|
result.inputFiles,
|
||||||
|
isNot(
|
||||||
|
contains(isA<File>().having((File f) => f.path, 'path', endsWith('.flutter-plugins'))),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWithoutContext('ignores files named .flutter-plugins-dependencies', () async {
|
||||||
|
environment.projectDir.childFile('.flutter-plugins-dependencies').createSync();
|
||||||
|
final BuildResult result = await buildSystem.build(allFilesTarget, environment);
|
||||||
|
expect(
|
||||||
|
result.inputFiles,
|
||||||
|
isNot(
|
||||||
|
contains(
|
||||||
|
isA<File>().having(
|
||||||
|
(File f) => f.path,
|
||||||
|
'path',
|
||||||
|
endsWith('.flutter-plugins-dependencies'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWithoutContext('ignores files ending with .xcconfig', () async {
|
||||||
|
environment.projectDir.childFile('foo.xcconfig').createSync();
|
||||||
|
final BuildResult result = await buildSystem.build(allFilesTarget, environment);
|
||||||
|
expect(
|
||||||
|
result.inputFiles,
|
||||||
|
isNot(contains(isA<File>().having((File f) => f.path, 'path', endsWith('.xcconfig')))),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
testWithoutContext('Does not re-invoke build if stamp is valid', () async {
|
testWithoutContext('Does not re-invoke build if stamp is valid', () async {
|
||||||
final BuildSystem buildSystem = setUpBuildSystem(fileSystem);
|
final BuildSystem buildSystem = setUpBuildSystem(fileSystem);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user