Unverified Commit 8220f8f4 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

add missing test case and handle wildcard removal (#30205)

parent 6b2e9394
...@@ -88,7 +88,11 @@ class _ManifestAssetBundle implements AssetBundle { ...@@ -88,7 +88,11 @@ class _ManifestAssetBundle implements AssetBundle {
return true; return true;
for (Directory directory in _wildcardDirectories.values) { for (Directory directory in _wildcardDirectories.values) {
if (directory.statSync().modified.isAfter(_lastBuildTimestamp)) { final DateTime dateTime = directory.statSync().modified;
if (dateTime == null) {
continue;
}
if (dateTime.isAfter(_lastBuildTimestamp)) {
return true; return true;
} }
} }
......
...@@ -96,6 +96,49 @@ flutter: ...@@ -96,6 +96,49 @@ flutter:
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => testFileSystem, FileSystem: () => testFileSystem,
}); });
testUsingContext('handle removal of wildcard directories', () async {
fs.file('.packages').createSync();
fs.file(fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true);
fs.file('pubspec.yaml')
..createSync()
..writeAsStringSync(r'''
name: example
flutter:
assets:
- assets/foo/
''');
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml');
// Expected assets:
// - asset manifest
// - font manifest
// - license file
// - assets/foo/bar.txt
expect(bundle.entries.length, 4);
expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), false);
// Delete the wildcard directory and update pubspec file.
fs.directory(fs.path.join('assets', 'foo')).deleteSync(recursive: true);
fs.file('pubspec.yaml')
..createSync()
..writeAsStringSync(r'''
name: example''');
// 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(manifestPath: 'pubspec.yaml'), true);
await bundle.build(manifestPath: 'pubspec.yaml');
// Expected assets:
// - asset manifest
// - font manifest
// - license file
// - assets/foo/bar.txt
expect(bundle.entries.length, 4);
}, overrides: <Type, Generator>{
FileSystem: () => testFileSystem,
});
}); });
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment