Sitelet https://github.com/flutter/flutter/pull/190770
Skip to content

[tool] Migrate CustomDevicesCommand to modular dependency injection - #190770

Merged
auto-submit[bot] merged 7 commits into
flutter:masterfrom
bkonyi:di/11-custom-devices
Sep 2, 2026
Merged

auto-submit[bot] merged 7 commits into
flutter:masterfrom
bkonyi:di/11-custom-devices

Conversation

@bkonyi

@bkonyi bkonyi commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Part 12 of the modular dependency injection migration.

Migrates CustomDevicesCommand and CustomDevicesConfig to explicit constructor dependency injection (ToolContext), eliminating ambient global references and adding hermetic unit tests.

Part of #47161

@github-actions github-actions Bot added tool Affects the "flutter" command-line tool. See also t: labels. team-android Owned by Android platform team team-ios Owned by iOS platform team team-macos Owned by the macOS platform team labels Aug 8, 2026
@bkonyi
bkonyi force-pushed the di/11-custom-devices branch 5 times, most recently from 2426710 to c7415a7 Compare August 12, 2026 18:17
@github-actions github-actions Bot removed the team-android Owned by Android platform team label Aug 12, 2026
@bkonyi
bkonyi force-pushed the di/11-custom-devices branch from c7415a7 to b4a6f77 Compare August 12, 2026 18:39
@github-actions github-actions Bot removed team-ios Owned by iOS platform team team-macos Owned by the macOS platform team labels Aug 28, 2026
@bkonyi
bkonyi force-pushed the di/11-custom-devices branch from 4feb1e7 to a049bcf Compare September 2, 2026 13:05
@bkonyi
bkonyi marked this pull request as ready for review September 2, 2026 13:05
@bkonyi bkonyi added the CICD Run CI/CD label Sep 2, 2026

@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 refactors CustomDevicesCommand and its subcommands to accept and utilize ToolContext directly, making individual tool dependencies optional and simplifying command instantiation. Additionally, the associated hermetic tests are updated to use testWithoutContext instead of testUsingContext. Feedback on the changes suggests simplifying the instantiation of CustomDevicesCommand in the test helper by omitting redundant arguments that are already provided via toolContext.

@bkonyi

bkonyi commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@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 refactors the CustomDevicesCommand and its subcommands to accept a ToolContext parameter instead of multiple individual dependencies, such as FileSystem, Logger, Platform, ProcessManager, Terminal, and OperatingSystemUtils. This change simplifies the constructors and dependency injection across custom_devices.dart and executable.dart. Additionally, the associated unit tests in custom_devices_test.dart have been updated to use testWithoutContext instead of testUsingContext, and FakeTerminal has been simplified by extending AnsiTerminal. There are no review comments, and I have no feedback to provide.

@bkonyi

bkonyi commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@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 refactors the CustomDevicesCommand and its subcommands to accept a unified ToolContext instead of multiple individual dependencies, simplifying the constructor signatures. The test suite has also been updated to migrate several tests from testUsingContext to testWithoutContext and simplify FakeTerminal by extending AnsiTerminal. Feedback on the changes suggests migrating one remaining test case to testWithoutContext that was missed during the refactoring to maintain consistency.

Comment thread packages/flutter_tools/test/commands.shard/hermetic/custom_devices_test.dart Outdated
@bkonyi

bkonyi commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@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 refactors CustomDevicesCommand and its subcommands to accept ToolContext and retrieve dependencies directly from it, simplifying constructor signatures and removing the test factory. Correspondingly, hermetic tests in custom_devices_test.dart are migrated from testUsingContext to testWithoutContext, and FakeTerminal is updated to extend AnsiTerminal. The review feedback suggests using the Terminal interface instead of the concrete AnsiTerminal in test helper signatures to ensure flexibility.

@bkonyi
bkonyi requested a review from chingjun September 2, 2026 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants