-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Test cross import lint #178693
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
Test cross import lint #178693
Conversation
Still some cleanup to do. Need to error when a test in the "known" list is not found anymore.
| filesByLibrary[Library.cupertino]!, | ||
| Library.material, | ||
| ); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about Material importing Cupertino?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Material importing Cupertino is allowed, at least for now. Material will continue to contain platform adaptive code (like Switch.adaptive), and it will also be responsible for testing interactions that involve both Material and Cupertino.
7cb58de to
a7f6e4f
Compare
| /// | ||
| /// The Material library should contain tests that verify behaviors involving | ||
| /// multiple libraries, such as platform adaptivity. Otherwise, these libraries | ||
| /// should not import each other in tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the bullet point rules in the "Overview" section of your flutter.dev/go/decoupling-framework-tests doc:
- The Cupertino library/tests should never import Material. It should test its widgets under a full-Cupertino scenario.
- The Material library should test its widgets in a full-Material scenario.
- Design languages are responsible for testing their interoperability with Widgets.
- Tests that cover interoperability between Material and Cupertino should go in Material. See the next section for when and how interoperability should be tested.
- The Widgets library/tests should never import Cupertino or Material.
What do you think of copying the bullet point rules here? I don't feel strongly about this, feel free to skip.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it, I hope we can properly communicate the ideas in that design doc. This also reminded me to create an issue (#179429) about explaining this sort of thing in the test README files.
This reverts commit e7cc6bc. The robot was right. This should bring the failures from 6 to 2.
loic-sharma
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
| /// Returns the Set of paths in `knownPaths` that are not in `files`. | ||
| static Set<String> _differencePaths(Set<String> knownPaths, Set<File> files) { | ||
| final Set<String> testPaths = files.map((File file) { | ||
| final prefix = RegExp('packages.flutter.test'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this work?
| final prefix = RegExp('packages.flutter.test'); | |
| final prefix = RegExp('packages[\/\\]flutter[\/\\]test'); |
I'm OK with the current solution though 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you update this, don't forget to also update _getUnknowns too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, more strict!
|
autosubmit label was removed for flutter/flutter/178693, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR. |
This PR adds a lint rule to catch imports between Material, Cupertino, and Widgets in tests. Spun out of #177029 and the Decoupling Tests design doc.
For now, Material will be the place to put tests that need to import both Material and Cupertino. See #178693 (comment).
I used #130523 as a reference to create this PR.