flutter_tools: flutter_tester is a host artifact (#162047)

This resolves the case where a `flutter test` run is invoked on a target
iOS/Android device, as in `flutter test -d iOS-device`.

Previously `CachedLocalEngineArtifacts` was returning `flutter_tester`
from the local target build directory. `flutter_tester` is a host build
artifact and thus should be returned from the local host engine
directory, not the local target build directory.

Some history: A long time ago, desktop artifacts were produced as part
of the host builds; and in fact, they still are, but ideally shouldn't
be. At some point we added target builds for macOS, Windows, and Linux
embedders, but failed to clean the target artifacts out of the host
builds. Similarly, the desktop target builds should ideally not produce
host artifacts, but that's less problematic. The conflation of the two
is likely why the existing code was working until now.

Related issue: https://github.com/flutter/flutter/issues/38935

Closes: https://github.com/flutter/flutter/issues/162045

## Pre-launch Checklist

- [X] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [X] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [X] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [X] I signed the [CLA].
- [X] I listed at least one issue that this PR fixes in the description
above.
- [X] I updated/added relevant documentation (doc comments with `///`).
- [X] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [X] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [X] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This commit is contained in:
Chris Bracken 2025-01-23 11:23:54 -08:00 committed by GitHub
parent 3fd4d0a61c
commit 1daa75598b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 12 deletions

View File

@ -1544,17 +1544,10 @@ class CachedLocalEngineArtifacts implements Artifacts {
}
String _flutterTesterPath(TargetPlatform platform) {
if (_platform.isLinux) {
return _fileSystem.path.join(
localEngineInfo.targetOutPath,
_artifactToFileName(Artifact.flutterTester, _platform),
);
} else if (_platform.isMacOS) {
return _fileSystem.path.join(localEngineInfo.targetOutPath, 'flutter_tester');
} else if (_platform.isWindows) {
return _fileSystem.path.join(localEngineInfo.targetOutPath, 'flutter_tester.exe');
}
throw Exception('Unsupported platform $platform.');
return _fileSystem.path.join(
localEngineInfo.hostOutPath,
_artifactToFileName(Artifact.flutterTester, _platform),
);
}
@override

View File

@ -516,7 +516,7 @@ void main() {
);
expect(
artifacts.getArtifactPath(Artifact.flutterTester),
fileSystem.path.join('/out', 'android_debug_unopt', 'flutter_tester'),
fileSystem.path.join('/out', 'host_debug_unopt', 'flutter_tester'),
);
expect(
artifacts.getArtifactPath(Artifact.engineDartSdkPath),