Skip to content

Conversation

christopherfujino
Copy link
Contributor

Description

I was seeing these tests fail locally for me on master from a mac (it passes on CI). The reason was that some of these tests were using the real artifacts and file systems.

Tests

This PR modifies tests to properly mock the artifacts and use memory file systems.

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. If not, delete the remainder of this section.
    • I wrote a design doc: https://flutter.dev/go/template Replace this with a link to your design doc's short link
    • I got input from the developer relations team, specifically from: Replace with the names of who gave advice
    • I wrote a migration guide: Replace with a link to your migration guide

@fluttergithubbot fluttergithubbot added the tool Affects the "flutter" command-line tool. See also t: labels. label Apr 10, 2020
@christopherfujino christopherfujino added c: contributor-productivity Team-specific productivity, code health, technical debt. team: flakes team-infra Owned by Infrastructure team labels Apr 10, 2020
}, overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(isWebEnabled: true),
FileSystem: () => MemoryFileSystem.test(),
ProcessManager: () => MockProcessManager(),
Copy link
Member

Choose a reason for hiding this comment

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

Does it make sense for the context override to check for the inverse (ProcessManager and no FileSystem)?
https://github.com/flutter/flutter/blob/master/packages/flutter_tools/test/src/context.dart#L64

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess the idea is if the process manager is mocked, then we shouldn't be hitting the file system at all?

Copy link
Member

Choose a reason for hiding this comment

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

@jonahwilliams or @zanderso can you think of a reason?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For context, I didn't change this because I knew for a fact it was hitting the file system, I just added it for consistency and since some of the other tests were hitting surprising globals.

Copy link
Member

Choose a reason for hiding this comment

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

The real ProcessManager will certainly touch the real file system, subverting the intent of the FileSystem context override. The other way around doesn't have the same problem, but it could make sense to require always overriding both together just for consistency.

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

Copy link
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.

LGTM

@christopherfujino christopherfujino merged commit 2adb1fc into flutter:master Apr 10, 2020
@christopherfujino christopherfujino deleted the fix-doctor-test branch April 10, 2020 21:01
// fail if the gen_snapshot binary is not present.
expect(testLogger.statusText, contains('No issues found!'));
expect(await FlutterValidatorDoctor().diagnose(verbose: false), isTrue);
// gen_snapshot is downloaded on demand, and the doctor should not
Copy link
Member

Choose a reason for hiding this comment

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

Is this true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess? For context #52574.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

c: contributor-productivity Team-specific productivity, code health, technical debt. team-infra Owned by Infrastructure team tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants