Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flutter_tools] remove most globals from asset system and remove Cache manipulation in unit tests #70011

Merged
merged 2 commits into from
Nov 10, 2020

Conversation

jonahwilliams
Copy link
Member

@jonahwilliams jonahwilliams commented Nov 7, 2020

Description

Removes most of the easy globals - there is still indirect usage via the flutter project. Removes most of the special flutter root setup the asset bundle tests have.

#47161

@flutter-dashboard flutter-dashboard bot added tool Affects the "flutter" command-line tool. See also t: labels. work in progress; do not review labels Nov 7, 2020
@google-cla google-cla bot added the cla: yes label Nov 7, 2020
@@ -48,12 +47,6 @@ $fontsSection
''');
}

void establishFlutterRoot() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of this removed code is a no-op now that the material manifest is stored in code

@@ -389,11 +399,284 @@ class ManifestAssetBundle implements AssetBundle {
)) font.descriptor,
];
}

DevFSStringContent _createAssetManifest(Map<_Asset, List<_Asset>> assetVariants) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change mostly takes the top-level private methods and makes them methods on the ManifestAssetBundle instead.

The other change is moving file creation out of the _Asset class to avoid the direct dep on the filesystem

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code could be simplified further but I chose to keep it mostly as is

@jonahwilliams jonahwilliams marked this pull request as ready for review November 9, 2020 23:45
@jonahwilliams jonahwilliams changed the title [flutter_tools] remove _most_ globals from asset system [flutter_tools] remove most globals from asset system and remove Cache manipulation in unit tests Nov 9, 2020
Copy link
Member

@jmagman jmagman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with nits

}

bool get assetFileExists => assetFile.existsSync();
// bool get assetFileExists => assetFile.existsSync();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -406,11 +689,11 @@ class _Asset {
/// A platform-independent URL representing the entry for the asset manifest.
final Uri entryUri;

File get assetFile {
return globals.fs.file(globals.fs.path.join(baseDir, globals.fs.path.fromUri(relativeUri)));
File createAssetFile(FileSystem fileSystem) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name sounds like it's creating the file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to lookupAssetFile which hopefully sounds more like what it does

@jonahwilliams jonahwilliams merged commit dbcd786 into flutter:master Nov 10, 2020
@jonahwilliams jonahwilliams deleted the more_globals_tests branch November 10, 2020 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants