Skip to content

[tool] Migrate LogsCommand to modular dependency injection - #190765

Merged
auto-submit[bot] merged 89 commits into
flutter:masterfrom
bkonyi:di/07-logs
Sep 4, 2026
Merged

auto-submit[bot] merged 89 commits into
flutter:masterfrom
bkonyi:di/07-logs

Conversation

@bkonyi

@bkonyi bkonyi commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Part 8 of the modular dependency injection migration.

  • Migrates LogsCommand to constructor dependency injection:
    LogsCommand({
      ApplicationPackageFactory? applicationPackageFactory,
      ProcessSignal? sigint,
      ProcessSignal? sigterm,
      super.toolContext,
    })
  • Resolves logger via toolContext?.logger ?? globals.logger for backwards compatibility with ambient callers.
  • Wires toolContext: toolDependencies.toolContext in executable.dart.
  • Migrates unit tests in packages/flutter_tools/test/commands.shard/hermetic/logs_test.dart to hermetic testWithoutContext.

Part of #188471

@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/07-logs branch 2 times, most recently from 9afdb6a to 0fac380 Compare August 11, 2026 19:48
bkonyi added 4 commits August 12, 2026 17:19
# Conflicts:
#	packages/flutter_tools/lib/src/context/tool_dependencies.dart
#	packages/flutter_tools/test/general.shard/context/dependency_injection_test.dart
@github-actions github-actions Bot removed the team-android Owned by Android platform team label Aug 12, 2026
bkonyi added 5 commits August 20, 2026 01:34
# Conflicts:
#	packages/flutter_tools/lib/executable.dart
#	packages/flutter_tools/lib/src/commands/clean.dart
#	packages/flutter_tools/lib/src/runner/flutter_command.dart
#	packages/flutter_tools/lib/src/runner/flutter_command_runner.dart
#	packages/flutter_tools/test/commands.shard/hermetic/clean_test.dart
#	packages/flutter_tools/test/src/test_flutter_command_runner.dart
…cutable.dart

Retain the shared singleton from `globals.doctor` in `DoctorCommand` until dependent commands (such as `DevicesCommand` and `EmulatorsCommand`) are migrated to dependency injection, avoiding instance divergence.
…allback

Makes `toolContext` optional on `LogsCommand` to preserve backwards compatibility with callers that instantiate `LogsCommand` without passing `toolContext`. Falls back to `globals.logger` when `toolContext` is omitted.
@bkonyi bkonyi added the CICD Run CI/CD label Sep 2, 2026
@bkonyi
bkonyi marked this pull request as ready for review September 2, 2026 03:44

@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 DoctorCommand and LogsCommand to support dependency injection by allowing dependencies such as Doctor, Logger, ProcessSignal, and ApplicationPackageFactory to be passed via their constructors, falling back to ambient globals when omitted. Comprehensive hermetic unit tests have been added to verify the behavior of both commands. The review feedback recommends catching specific errors instead of the broad Error class in DoctorCommand to prevent swallowing critical programming errors.

Comment thread packages/flutter_tools/lib/src/commands/doctor.dart
@bkonyi
bkonyi requested a review from chingjun September 2, 2026 17:37
chingjun
chingjun previously approved these changes Sep 2, 2026
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 2, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Sep 2, 2026
@jtmcdole
jtmcdole removed this pull request from the merge queue due to a manual request Sep 2, 2026
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 2, 2026
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 4, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Sep 4, 2026
Merged via the queue into flutter:master with commit 74cef67 Sep 4, 2026
25 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 4, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Sep 5, 2026
flutter/flutter@5a6cfa7...63170e9

2026-09-05 [email protected] Roll Dart SDK from 6882c3b4b542 to 77094991d1c1 (1 revision) (flutter/flutter#192339)
2026-09-05 [email protected] Roll Skia from 10652f9d64d6 to db200e27a634 (1 revision) (flutter/flutter#192338)
2026-09-05 [email protected] Roll Fuchsia Linux SDK from FgDQeF6jb1dVRVh3K... to _IgixhH4vEgdz9Oqn... (flutter/flutter#192333)
2026-09-05 [email protected] Roll Dart SDK from 5744c2480a12 to 6882c3b4b542 (1 revision) (flutter/flutter#192331)
2026-09-05 [email protected] Roll Skia from 9b1e5fd08d2c to 10652f9d64d6 (4 revisions) (flutter/flutter#192329)
2026-09-05 [email protected] ci(engine): target ignore_phone|none for new macs (flutter/flutter#192317)
2026-09-04 [email protected] [devicelab] Fix Mac ios_universal_link_test CI build and scheme configuration (flutter/flutter#192321)
2026-09-04 [email protected] Roll Dart SDK from 5501d02b583d to 5744c2480a12 (5 revisions) (flutter/flutter#192316)
2026-09-04 [email protected] [iOS] Add native deep link lifecycle integration tests for UIScene plugins (flutter/flutter#192173)
2026-09-04 [email protected] Roll Skia from 93ac1e630d1d to 9b1e5fd08d2c (3 revisions) (flutter/flutter#192314)
2026-09-04 [email protected] [tool] Migrate AssembleCommand and GenerateCommand to modular dependency injection (flutter/flutter#190773)
2026-09-04 [email protected] [tool] Migrate Apple build subcommands and toolchain to modular dependency injection (flutter/flutter#190780)
2026-09-04 [email protected] [flutter_tools] Safely handle non-JSON messages in test stream parsers (flutter/flutter#192089)
2026-09-04 [email protected] [tool] Migrate LogsCommand to modular dependency injection (flutter/flutter#190765)
2026-09-04 [email protected] [tool] Migrate DevicesCommand to modular dependency injection (flutter/flutter#190768)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
victorsanni pushed a commit to victorsanni/packages that referenced this pull request Sep 9, 2026
…r#12767)

flutter/flutter@5a6cfa7...63170e9

2026-09-05 [email protected] Roll Dart SDK from 6882c3b4b542 to 77094991d1c1 (1 revision) (flutter/flutter#192339)
2026-09-05 [email protected] Roll Skia from 10652f9d64d6 to db200e27a634 (1 revision) (flutter/flutter#192338)
2026-09-05 [email protected] Roll Fuchsia Linux SDK from FgDQeF6jb1dVRVh3K... to _IgixhH4vEgdz9Oqn... (flutter/flutter#192333)
2026-09-05 [email protected] Roll Dart SDK from 5744c2480a12 to 6882c3b4b542 (1 revision) (flutter/flutter#192331)
2026-09-05 [email protected] Roll Skia from 9b1e5fd08d2c to 10652f9d64d6 (4 revisions) (flutter/flutter#192329)
2026-09-05 [email protected] ci(engine): target ignore_phone|none for new macs (flutter/flutter#192317)
2026-09-04 [email protected] [devicelab] Fix Mac ios_universal_link_test CI build and scheme configuration (flutter/flutter#192321)
2026-09-04 [email protected] Roll Dart SDK from 5501d02b583d to 5744c2480a12 (5 revisions) (flutter/flutter#192316)
2026-09-04 [email protected] [iOS] Add native deep link lifecycle integration tests for UIScene plugins (flutter/flutter#192173)
2026-09-04 [email protected] Roll Skia from 93ac1e630d1d to 9b1e5fd08d2c (3 revisions) (flutter/flutter#192314)
2026-09-04 [email protected] [tool] Migrate AssembleCommand and GenerateCommand to modular dependency injection (flutter/flutter#190773)
2026-09-04 [email protected] [tool] Migrate Apple build subcommands and toolchain to modular dependency injection (flutter/flutter#190780)
2026-09-04 [email protected] [flutter_tools] Safely handle non-JSON messages in test stream parsers (flutter/flutter#192089)
2026-09-04 [email protected] [tool] Migrate LogsCommand to modular dependency injection (flutter/flutter#190765)
2026-09-04 [email protected] [tool] Migrate DevicesCommand to modular dependency injection (flutter/flutter#190768)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
victorsanni pushed a commit to victorsanni/packages that referenced this pull request Sep 9, 2026
…r#12767)

flutter/flutter@5a6cfa7...63170e9

2026-09-05 [email protected] Roll Dart SDK from 6882c3b4b542 to 77094991d1c1 (1 revision) (flutter/flutter#192339)
2026-09-05 [email protected] Roll Skia from 10652f9d64d6 to db200e27a634 (1 revision) (flutter/flutter#192338)
2026-09-05 [email protected] Roll Fuchsia Linux SDK from FgDQeF6jb1dVRVh3K... to _IgixhH4vEgdz9Oqn... (flutter/flutter#192333)
2026-09-05 [email protected] Roll Dart SDK from 5744c2480a12 to 6882c3b4b542 (1 revision) (flutter/flutter#192331)
2026-09-05 [email protected] Roll Skia from 9b1e5fd08d2c to 10652f9d64d6 (4 revisions) (flutter/flutter#192329)
2026-09-05 [email protected] ci(engine): target ignore_phone|none for new macs (flutter/flutter#192317)
2026-09-04 [email protected] [devicelab] Fix Mac ios_universal_link_test CI build and scheme configuration (flutter/flutter#192321)
2026-09-04 [email protected] Roll Dart SDK from 5501d02b583d to 5744c2480a12 (5 revisions) (flutter/flutter#192316)
2026-09-04 [email protected] [iOS] Add native deep link lifecycle integration tests for UIScene plugins (flutter/flutter#192173)
2026-09-04 [email protected] Roll Skia from 93ac1e630d1d to 9b1e5fd08d2c (3 revisions) (flutter/flutter#192314)
2026-09-04 [email protected] [tool] Migrate AssembleCommand and GenerateCommand to modular dependency injection (flutter/flutter#190773)
2026-09-04 [email protected] [tool] Migrate Apple build subcommands and toolchain to modular dependency injection (flutter/flutter#190780)
2026-09-04 [email protected] [flutter_tools] Safely handle non-JSON messages in test stream parsers (flutter/flutter#192089)
2026-09-04 [email protected] [tool] Migrate LogsCommand to modular dependency injection (flutter/flutter#190765)
2026-09-04 [email protected] [tool] Migrate DevicesCommand to modular dependency injection (flutter/flutter#190768)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
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