[material_ui] Reduce the material_ui non-wasm web test suite - #12763
[material_ui] Reduce the material_ui non-wasm web test suite#12763elliette wants to merge 3 commits into
material_ui non-wasm web test suite#12763Conversation
cc973ff to
f4fdda0
Compare
material_ui web test suitematerial_ui web test suite
material_ui web test suitematerial_ui non-wasm web test suite
There was a problem hiding this comment.
Code Review
This pull request adds support for a --package-tags option to the dart-test command in the repository tooling, enabling packages to run only tests matching a specified tag. The material_ui package is configured to run a reduced set of web tests using the reduced-web-test-set tag, and CI configurations are updated to utilize this new option. Feedback on the changes suggests handling cases where the package tags YAML file is empty or contains only comments to prevent a misleading error message when loadYaml returns null.
| final Object? yaml = loadYaml(file.readAsStringSync()); | ||
| if (yaml is YamlMap) { | ||
| for (final MapEntry<dynamic, dynamic> entry in yaml.entries) { | ||
| final pkg = entry.key.toString(); | ||
| final dynamic val = entry.value; | ||
| if (val != null) { | ||
| packageTags[pkg] = val.toString(); | ||
| } | ||
| } | ||
| } else { | ||
| printError('The package tags file "$arg" is not a valid YAML map.'); | ||
| throw ToolExit(exitInvalidArguments); | ||
| } |
There was a problem hiding this comment.
If the YAML file is empty or contains only comments, loadYaml will return null. Currently, this will fall through to the else block and throw a ToolExit with a confusing error message ('is not a valid YAML map'). It would be more robust to handle null gracefully by returning an empty map.
final Object? yaml = loadYaml(file.readAsStringSync());
if (yaml == null) {
_packageTags = packageTags;
return packageTags;
}
if (yaml is YamlMap) {
for (final MapEntry<dynamic, dynamic> entry in yaml.entries) {
final pkg = entry.key.toString();
final dynamic val = entry.value;
if (val != null) {
packageTags[pkg] = val.toString();
}
}
} else {
printError('The package tags file "$arg" is not a valid YAML map.');
throw ToolExit(exitInvalidArguments);
}| /// Returns the tag to apply for [package] based on `--package-tags`, or null | ||
| /// if none. | ||
| String? _getTagForPackage(RepositoryPackage package) { | ||
| final Map<String, String> packageTags = _getPackageTags(); |
There was a problem hiding this comment.
I can do a full review on Tuesday, but as a quick note generally global state initialization goes in an @override Future<void> initializeRun() async, which is called once per run rather than once per package. (Obviously the cost is pretty low here, but there's no need to read and parse a repo-level file N times.)
Work towards flutter/flutter#192308
Introduce new
--package-tagsflag that can be used to specify which flags to filter a package's tests with. In the case of theweb_dart_unit_tests, we specify thatmaterial_uishould filter on the newreduced_web_test_settag.Pre-Review Checklist
[shared_preferences]///).changelog exemption: only test/CI changes
If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2