Repository navigation
Conversation
…oject platforms Fixes an issue where flutter drive targeted devices unsupported by the project when building from source due to an inverted includeDevicesUnsupportedByProject condition in DriveCommand. Also adds defensive handling in DefaultDriverService.start when ApplicationPackageFactory returns null. Fixes flutter#134073
…-134073 # Conflicts: # packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart
…t in drive_test.dart
Resolves conflicts with upstream `DriverService` DI migration by preserving `FlutterDriverService` constructor parameters and extracting `missingApplicationPackageMessage` in `resident_runner.dart` to share error formatting between `runHot`, `runCold`, and `FlutterDriverService.start`. Simplifies `drive_test.dart` using `_TestDeviceManager` and `FakeDevice`. Fixes flutter#134073
There was a problem hiding this comment.
Code Review
This pull request modifies the flutter drive command to include devices unsupported by the project when using a prebuilt application binary, while ignoring them when building from source. It also refactors the missing application package error reporting into a shared helper function and adds corresponding tests. A critical issue was identified in drive_service.dart where destructuring ToolContext with :FileSystem fs will cause a compilation error because the property is named fileSystem.
| applicationBinary: applicationBinary, | ||
| ); | ||
| if (_applicationPackage == null) { | ||
| final ToolContext(:FileSystem fs, :FlutterProjectFactory projectFactory) = toolContext; |
There was a problem hiding this comment.
The ToolContext class defines the property as fileSystem, not fs. Destructuring with :FileSystem fs (which is shorthand for fs: FileSystem fs) will cause a compilation error because the getter fs does not exist on ToolContext. Use fileSystem: FileSystem fs to correctly map the fileSystem property to the local variable fs.
| final ToolContext(:FileSystem fs, :FlutterProjectFactory projectFactory) = toolContext; | |
| final ToolContext(fileSystem: FileSystem fs, :FlutterProjectFactory projectFactory) = toolContext; |
Restores `packages/flutter_tools/lib/src/resident_runner.dart` to base by calling `getMissingPackageHintForPlatform` directly in `FlutterDriverService.start` when `applicationBinary == null`, avoiding a new public helper while keeping the `ToolExit` message concise. Trims 8 unused `ApplicationPackageFactory` overrides from `packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart`, retaining the override only on the 3 `ThrowingScreenshotDevice` tests. Previous output: ```text _TypeError: type 'Null' is not a subtype of type 'IOSApp' of 'package' ``` Current output: ```text No supported devices connected. The following devices were found, but are not supported by this project: iPhone 16 Pro (mobile) • ios-sim-1 • ios • Test SDK (1.2.3) (simulator) If you would like your app to run on ios, consider running `flutter create .` to generate projects for these platforms. ``` Current output (explicit `-d` targeting unsupported platform): ```text Error: No application found for TargetPlatform.ios. Is your project missing an ios/Runner/Info.plist? Consider running "flutter create ." to create one. ``` Fixes flutter#134073
Resolves merge conflicts with flutter#196571 by keeping both `hook_runner.dart` and `project.dart` imports in `drive_service.dart` and passing `assetBundleFactory`, `devtoolsLauncher`, and `applicationPackages` directly to `DriveCommand` in `drive_test.dart`. Fixes flutter#134073
Resolves merge conflicts with flutter#196571, picks up flutter#196572 and flutter#196740, and converts the remaining prebuilt-binary filter test in `drive_test.dart` to `testWithoutContext`. Fixes flutter#134073
… drive tests Merges `upstream/master` into `investigation/issue-134073` (resolving test conflicts from `testUsingContext` and `testWithoutContext` removals), updates `DriveCommand.targetedDevice` to also allow devices unsupported by the project when `--use-existing-app` is set, uses a local promoted `ApplicationPackage` variable in `FlutterDriverService.start`, and simplifies `drive_test.dart` to reuse `createToolContext()` and `createCommandRunner()`. Previous output: ```text _TypeError: type 'Null' is not a subtype of type 'IOSApp' of 'package' ``` Current output (default device selection): ```text No supported devices connected. The following devices were found, but are not supported by this project: iPhone 16 Pro (mobile) • ios-sim-1 • ios • Test SDK (1.2.3) (simulator) If you would like your app to run on ios, consider running `flutter create .` to generate projects for these platforms. ``` Current output (explicit `-d` targeting unsupported platform): ```text Error: No application found for TargetPlatform.ios. Is your project missing an ios/Runner/Info.plist? Consider running "flutter create ." to create one. ``` Fixes flutter#134073
Fixes #134073
flutter drivepreviously invertedincludeDevicesUnsupportedByProject(applicationBinaryPath == null), so building from source could auto-select a device whose platform the project does not support. WhengetPackageForPlatformthen returnednull,FlutterDriverService.startpassednullstraight todevice.startApp, crashing with a covariant_TypeError(which also happened when explicitly targeting an unsupported platform with-d).This change fixes the device-filter condition (allowing unsupported project platforms only for
--use-application-binaryor--use-existing-app) and makesFlutterDriverService.startthrow aToolExitwith the platform's missing-package hint when noApplicationPackageis found.Previous output:
Current output (default device selection):
Current output (explicit
-dtargeting unsupported platform):Pre-launch Checklist
///).