Skip to content

[material_ui, cupertino_ui, go_router] Command to test dart fixes - #12390

Open
justinmc wants to merge 5 commits into
flutter:mainfrom
justinmc:test-dart-fixes
Open

[material_ui, cupertino_ui, go_router] Command to test dart fixes#12390
justinmc wants to merge 5 commits into
flutter:mainfrom
justinmc:test-dart-fixes

Conversation

@justinmc

@justinmc justinmc commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

This PR creates a new repo-level CI command to run the dart fix tests in relevant packages. Before this PR, go_router had its own script to run its dart fix tests, and material_ui and cupertino_ui had dart fix tests that were not being run. After this PR, all of the above are run via the new command.

Part of flutter/flutter#182568

@justinmc justinmc self-assigned this Aug 6, 2026
@github-actions github-actions Bot added p: go_router triage-framework Should be looked at in framework triage labels Aug 7, 2026
@justinmc justinmc added the CICD Run CI/CD label Aug 7, 2026
@justinmc
justinmc requested a review from stuartmorgan-g August 7, 2026 19:52
@justinmc
justinmc marked this pull request as ready for review August 7, 2026 19:52

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request replaces the standalone tool/run_tests.dart script with a new test-dart-fixes command in the repository tooling, implemented in TestDartFixes. This command automates running Dart fix tests for packages containing a test_fixes directory. Feedback on the implementation highlights opportunities to improve testability by using the package's file system and the configured processRunner instead of hardcoded LocalFileSystem and Process.start calls. Additionally, minor typos in string interpolation within error messages were identified.

Comment on lines +79 to +81
static Future<Directory> _createTestDirectory(RepositoryPackage package) async {
const fileSystem = LocalFileSystem();
final Directory testTempDirectory = await fileSystem.systemTempDirectory.createTemp();

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.

high

Using LocalFileSystem directly prevents the command from being unit-tested with a mock/memory file system. Use the file system from the package's directory (package.directory.fileSystem) instead.

Suggested change
static Future<Directory> _createTestDirectory(RepositoryPackage package) async {
const fileSystem = LocalFileSystem();
final Directory testTempDirectory = await fileSystem.systemTempDirectory.createTemp();
static Future<Directory> _createTestDirectory(RepositoryPackage package) async {
final FileSystem fileSystem = package.directory.fileSystem;
final Directory testTempDirectory = await fileSystem.systemTempDirectory.createTemp();

Comment on lines +131 to +140
static Future<int> _runProcess(
String command,
List<String> arguments, {
String? workingDirectory,
}) async {
final Process process = await _streamOutput(
Process.start(command, arguments, workingDirectory: workingDirectory),
);
return process.exitCode;
}

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.

high

Calling Process.start directly from dart:io bypasses the processRunner passed to the constructor, which prevents mocking process execution in unit tests. Consider making these helper methods non-static and using processRunner to run the processes.

try {
testDirectory = await _createTestDirectory(package);
} catch (error) {
return PackageResult.fail(['Failed to create temporary test directory: $error}']);

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.

medium

There is a typo in the string interpolation: $error} has an extra closing brace. It should be $error.

Suggested change
return PackageResult.fail(['Failed to create temporary test directory: $error}']);
return PackageResult.fail(['Failed to create temporary test directory: $error']);

}
result = PackageResult.success();
} catch (error) {
result = PackageResult.fail(['Dart fix tests failed: $error}']);

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.

medium

There is a typo in the string interpolation: $error} has an extra closing brace. It should be $error.

Suggested change
result = PackageResult.fail(['Dart fix tests failed: $error}']);
result = PackageResult.fail(['Dart fix tests failed: $error']);

@justinmc

justinmc commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Questions for @stuartmorgan-g in code review:

  • There are only 3 packages that support this, so it leaves a bunch of spam in the terminal saying "skipped x package". Is that ok or is there a way I should be avoiding that?
  • I deleted go_router's script that did this previously, but is there anything else that I should clean up there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD p: go_router triage-framework Should be looked at in framework triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant