Skip to content

Precache platform filter change#53701

Merged
stuartmorgan-g merged 4 commits intoflutter:masterfrom
stuartmorgan-g:precache-platform-filter-change
Apr 1, 2020
Merged

Precache platform filter change#53701
stuartmorgan-g merged 4 commits intoflutter:masterfrom
stuartmorgan-g:precache-platform-filter-change

Conversation

@stuartmorgan-g
Copy link
Copy Markdown
Contributor

Description

Makes the following changes to the behavior of precache:

  • The --all-platforms flags now fetches all artifacts, rather than just
    turning off platform filtering of selected artifacts.
  • Explicitly requested artifacts are no longer subject to platform
    filtering. E.g., 'precache --ios' will download iOS artifacts on
    Windows and Linux (but 'precache' without an 'ios' flag will still
    only download iOS artifacts on macOS).
  • Desktop platform artifacts now respect the bypassing of platform
    filtering.

Related Issues

Fixes #53272

Tests

I added the following tests: New tests for all of the above at the cache.dart and precache.dart levels.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

  • No, no existing tests failed, so this is not a breaking change.
  • Yes, this is a breaking change.

Makes the following changes to the behavior of precache:
- The --all-platforms flags now fetches all artifacts, rather than just
  turning off platform filtering of selected artifacts.
- Explicitly requested artifacts are no longer subject to platform
  filtering. E.g., 'precache --ios' will download iOS artifacts on
  Windows and Linux (but 'precache' without an 'ios' flag will still
  only download iOS artifacts on macOS).
- Desktop platform artifacts now respect the bypassing of platform
  filtering.

Fixes flutter#53272
@fluttergithubbot fluttergithubbot added the tool Affects the "flutter" command-line tool. See also t: labels. label Mar 31, 2020
Copy link
Copy Markdown
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

Overall change LGTM with nits

testUsingContext('macOS desktop artifacts ignore filtering when requested', () {
final MockCache mockCache = MockCache();
final MacOSEngineArtifacts artifacts = MacOSEngineArtifacts(mockCache);
when(mockCache.includeAllPlatforms).thenReturn(false);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: here and elsewhere separate the test setup from the expectation with a newline.

when(mockCache.platformOverrideArtifacts).thenReturn(<String>{'macos'});
expect(artifacts.getBinaryDirs(), isNotEmpty);
}, overrides: <Type, Generator> {
Platform: () => FakePlatform()..operatingSystem = 'linux',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: prefer constructor instead of setter

Suggested change
Platform: () => FakePlatform()..operatingSystem = 'linux',
Platform: () => FakePlatform(operatingSystem: 'linux'),


/// Returns a reverse mapping of _expandedArtifacts, from child artifact name
/// to umbrella name.
Map<String, String> get _umbrellaForArtifactMap {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since both of these do non-trivial calculations, I would make them methods like _getUmbrellaForArtifactMap()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You could also use a for element instead, if you'd like

final Map<String, String> reverseMap = <String, String>{
  for (MapEntry<String, List<String>> entry in _expandedArtifacts.entries)
    for (String child in entry.value)
      childArtifactName: entry.key
};

@stuartmorgan-g stuartmorgan-g merged commit 445b5a1 into flutter:master Apr 1, 2020
@stuartmorgan-g stuartmorgan-g deleted the precache-platform-filter-change branch April 1, 2020 17:55
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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.

Allow bypassing host filtering on downloaded artifacts

4 participants