Watch wildcard directories in addition to asset bundle (#29883)

This commit is contained in:
Jonah Williams
2019-03-26 21:40:53 -07:00
committed by GitHub
parent 141f87b327
commit bafe7cbbb4
2 changed files with 62 additions and 1 deletions

View File

@@ -56,6 +56,46 @@ void main() {
}, overrides: <Type, Generator>{
FileSystem: () => testFileSystem,
});
testUsingContext('wildcard directories are updated when filesystem changes', () 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);
// Adding a file should update the stat of the directory, but instead
// we need to fully recreate it.
fs.directory(fs.path.join('assets', 'foo')).deleteSync(recursive: true);
fs.file(fs.path.join('assets', 'foo', 'fizz.txt')).createSync(recursive: true);
fs.file(fs.path.join('assets', 'foo', 'bar.txt')).createSync();
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
// - assets/foo/fizz.txt
expect(bundle.entries.length, 5);
}, overrides: <Type, Generator>{
FileSystem: () => testFileSystem,
});
});
}