Repository navigation
[tool] Migrate TestCompiler and WebTestCompiler to modular dependency injection - #192923
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors TestCompiler and WebTestCompiler to accept a ToolContext parameter, facilitating dependency injection and improving testability by reducing reliance on global variables. The review feedback suggests simplifying the WebTestCompiler constructor by making artifacts nullable to eliminate the custom sentinel class, avoiding redundant fallback context evaluations in TestCompiler by handling nullable contexts internally within _computeTestFilePath, and making the _FallbackToolContext constructor const.
| static String _computeTestFilePath( | ||
| ToolContext toolContext, | ||
| FlutterProject? flutterProject, | ||
| BuildInfo buildInfo, | ||
| ) { | ||
| final ToolContext(:Config config, :FileSystem fs) = toolContext; |
There was a problem hiding this comment.
Update _computeTestFilePath to accept a nullable ToolContext? and fall back to const _FallbackToolContext() internally. This simplifies the call site in the constructor.
| static String _computeTestFilePath( | |
| ToolContext toolContext, | |
| FlutterProject? flutterProject, | |
| BuildInfo buildInfo, | |
| ) { | |
| final ToolContext(:Config config, :FileSystem fs) = toolContext; | |
| static String _computeTestFilePath( | |
| ToolContext? toolContext, | |
| FlutterProject? flutterProject, | |
| BuildInfo buildInfo, | |
| ) { | |
| final ToolContext context = toolContext ?? const _FallbackToolContext(); | |
| final ToolContext(:Config config, :FileSystem fs) = context; |
| fileSystem: fs, | ||
| shutdownHooks: shutdownHooks, | ||
| config: config, | ||
| targetPlatform: TargetPlatform.tester, |
There was a problem hiding this comment.
spurious change because AI does not know shorthands?
There was a problem hiding this comment.
It does know about it, but chose to ignore it. Switch this back to use a dot shorthand.
…tter#192924) ## Description This pull request migrates `CoverageCollector` in `flutter_tools` to modular dependency injection using `ToolContext`. This is Layer 21b in the modular dependency injection migration for the testing subsystem (stacked on Layer 21a [flutter#192923](flutter#192923)). ### Fork Compare Link * Compare: bkonyi/flutter@master...di/21b-coverage-collector Part of [flutter#188471](flutter#188471). ## Tests * `test/general.shard/coverage_collector_test.dart`
…tter#192924) ## Description This pull request migrates `CoverageCollector` in `flutter_tools` to modular dependency injection using `ToolContext`. This is Layer 21b in the modular dependency injection migration for the testing subsystem (stacked on Layer 21a [flutter#192923](flutter#192923)). ### Fork Compare Link * Compare: bkonyi/flutter@master...di/21b-coverage-collector Part of [flutter#188471](flutter#188471). ## Tests * `test/general.shard/coverage_collector_test.dart`
…tter#192924) ## Description This pull request migrates `CoverageCollector` in `flutter_tools` to modular dependency injection using `ToolContext`. This is Layer 21b in the modular dependency injection migration for the testing subsystem (stacked on Layer 21a [flutter#192923](flutter#192923)). ### Fork Compare Link * Compare: bkonyi/flutter@master...di/21b-coverage-collector Part of [flutter#188471](flutter#188471). ## Tests * `test/general.shard/coverage_collector_test.dart`
…injection (flutter#190789) ## Description This pull request migrates `TestCommand`, `FlutterTestRunner`, `FlutterPlatform`, `FlutterWebPlatform`, and `TestGoldenComparator` to modular dependency injection using `ToolContext`. This is Layer 21c in the modular dependency injection migration for the testing subsystem (Layer 21a [flutter#192923](flutter#192923) and Layer 21b [flutter#192924](flutter#192924) have merged into `master`). ### Fork Compare Link * Compare: bkonyi/flutter@master...di/21-testing-subsystem Part of [flutter#188471](flutter#188471). ## Tests * `test/commands.shard/hermetic/test_test.dart` * `test/general.shard/flutter_platform_test.dart` * `test/commands.shard/hermetic/flutter_web_platform_test.dart` * `test/general.shard/test/test_golden_comparator_test.dart` * `test/integration.shard/test_golden_comparator_test.dart`
Description
This pull request migrates
TestCompilerandWebTestCompilerinflutter_toolsto modular dependency injection usingToolContext.This is Layer 21a in the modular dependency injection migration for the testing subsystem.
Fork Compare Link
Tests
test/general.shard/test/test_compiler_test.darttest/general.shard/test/web_test_compiler_test.dart