Repository navigation
[flutter_tools] Fix package URI resolution in --experimental-faster-testing - #190875
Conversation
…esting When `--experimental-faster-testing` is enabled, the runner reads the package config using `Uri.file(flutterProject.directory.path)` which lacked a trailing slash. This caused relative resolution (using `../`) to resolve to the parent of the project directory (one level too high). This fix replaces the base URI with `packageConfigFile.uri` which correctly resolves. A regression test verifying the output `rootUri` was added. Fixes flutter#190784
There was a problem hiding this comment.
Code Review
This pull request updates the Flutter test runner to parse the package configuration using the URI of the package configuration file itself rather than the project directory path, and adds a test to verify the root URI of the package configuration. The feedback suggests using the absolute URI of the package configuration file to prevent potential resolution failures if the path is relative.
| projectPackageConfig = PackageConfig.parseBytes( | ||
| packageConfigFile.readAsBytesSync(), | ||
| Uri.file(flutterProject.directory.path), | ||
| packageConfigFile.uri, |
There was a problem hiding this comment.
Using packageConfigFile.absolute.uri instead of packageConfigFile.uri is safer and more robust. If packageConfigFile is resolved from a relative path, packageConfigFile.uri will also be relative. This can cause PackageConfig.parseBytes to resolve package root URIs as relative URIs, which may lead to resolution failures if the current working directory changes or if other parts of the tool expect absolute URIs. Ensuring the base URI is absolute prevents these potential issues.
| packageConfigFile.uri, | |
| packageConfigFile.absolute.uri, |
There was a problem hiding this comment.
Updated to use packageConfigFile.absolute.uri across all package config parsing calls in this file in commit 1cf6a42.
When
--experimental-faster-testingis enabled, the runner reads the package config usingUri.file(flutterProject.directory.path)which lacked a trailing slash. This caused relative resolution (using../) to resolve to the parent of the project directory (one level too high).This fix replaces the base URI with
packageConfigFile.uriwhich correctly resolves. A regression test verifying the outputrootUriwas added.Fixes #190784
Pre-launch Checklist
///).