Unverified Commit da36bd6f authored by Andrew Kolos's avatar Andrew Kolos Committed by GitHub

Stop recursively including assets from asset folders (#120167)

* add test

* fix

* use preexisting testFileSystem

* fix variant tests

* Revert "use preexisting testFileSystem"

This reverts commit b6df288ef4a6ff007ecd984e98a1a3f2001ad242.

* nit: grammar
parent f2e89755
......@@ -909,22 +909,6 @@ class ManifestAssetBundle implements AssetBundle {
attributedPackage: attributedPackage,
);
}
final Iterable<Directory> nonVariantSubDirectories = entities
.whereType<Directory>()
.where((Directory directory) => !_assetVariantDirectoryRegExp.hasMatch(directory.basename));
for (final Directory dir in nonVariantSubDirectories) {
final String relativePath = _fileSystem.path.relative(dir.path, from: assetBase);
final Uri relativePathsUri = Uri.directory(relativePath, windows: _platform.isWindows);
_parseAssetsFromFolder(packageConfig,
flutterManifest,
assetBase,
cache,
result,
relativePathsUri
);
}
}
void _parseAssetFromFile(
......
......@@ -9,11 +9,15 @@ import 'package:file/memory.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/asset.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/user_messages.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/bundle_builder.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/devfs.dart';
import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/project.dart';
import 'package:standard_message_codec/standard_message_codec.dart';
import '../src/common.dart';
......@@ -69,6 +73,59 @@ void main() {
ProcessManager: () => FakeProcessManager.any(),
});
testWithoutContext('wildcard directories do not include subdirectories', () async {
final Platform platform = FakePlatform();
final FileSystem fs = MemoryFileSystem.test();
Cache.flutterRoot = Cache.defaultFlutterRoot(platform: platform, fileSystem: fs, userMessages: UserMessages());
fs.file('.packages').createSync();
fs.file('pubspec.yaml').writeAsStringSync(
'''
name: test
dependencies:
flutter:
sdk: flutter
flutter:
assets:
- assets/foo/
- assets/bar/lizard.png
'''
);
final List<String> assets = <String>[
'assets/foo/dog.png',
'assets/foo/sub/cat.png',
'assets/bar/lizard.png',
'assets/bar/sheep.png'
];
for (final String asset in assets) {
final File assetFile = fs.file(asset);
assetFile.createSync(recursive: true);
assetFile.writeAsStringSync(asset);
}
final ManifestAssetBundle bundle = ManifestAssetBundle(
logger: BufferLogger.test(),
fileSystem: fs,
platform: platform,
);
await bundle.build(
packagesPath: '.packages',
flutterProject: FlutterProject.fromDirectoryTest(fs.currentDirectory),
);
expect(bundle.entries.keys, unorderedEquals(<String>[
'AssetManifest.json',
'AssetManifest.bin',
'FontManifest.json',
'NOTICES.Z',
'assets/foo/dog.png',
'assets/bar/lizard.png'
]));
});
testUsingContext('wildcard directories are updated when filesystem changes', () async {
final File packageFile = globals.fs.file('.packages')..createSync();
globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true);
......
......@@ -54,6 +54,9 @@ dependencies:
flutter:
assets:
- assets/
- assets/notAVariant/
- assets/folder/
- assets/normalFolder/
'''
);
});
......@@ -184,6 +187,7 @@ dependencies:
flutter:
assets:
- assets/
- assets/somewhereElse/
'''
);
});
......
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