diff --git a/packages/flutter_tools/lib/src/runner/local_engine.dart b/packages/flutter_tools/lib/src/runner/local_engine.dart index 50537146d2..e89a15a9bf 100644 --- a/packages/flutter_tools/lib/src/runner/local_engine.dart +++ b/packages/flutter_tools/lib/src/runner/local_engine.dart @@ -150,8 +150,10 @@ class LocalEngineLocator { // Determine the host engine directory associated with the local engine: // Strip '_sim_' since there are no host simulator builds. String _getHostEngineBasename(String localEngineBasename) { - if (localEngineBasename.startsWith('web_') || localEngineBasename.startsWith('wasm_')) { - // Don't modify the web local engine's basename. + if (localEngineBasename.startsWith('web_') || + localEngineBasename.startsWith('wasm_') || + localEngineBasename.startsWith('host_')) { + // Don't modify the web or host local engine's basename. return localEngineBasename; } diff --git a/packages/flutter_tools/test/general.shard/runner/local_engine_test.dart b/packages/flutter_tools/test/general.shard/runner/local_engine_test.dart index 7105809b3b..e69d7659d5 100644 --- a/packages/flutter_tools/test/general.shard/runner/local_engine_test.dart +++ b/packages/flutter_tools/test/general.shard/runner/local_engine_test.dart @@ -146,6 +146,30 @@ void main() { expect(logger.traceText, contains('Local engine source at /arbitrary/engine/src')); }); + testWithoutContext('works if local engine is host engine with suffixes', () async { + final FileSystem fileSystem = MemoryFileSystem.test(); + final Directory localEngine = fileSystem + .directory('$kArbitraryEngineRoot/src/out/host_debug_unopt_arm64/') + ..createSync(recursive: true); + + final BufferLogger logger = BufferLogger.test(); + final LocalEngineLocator localEngineLocator = LocalEngineLocator( + fileSystem: fileSystem, + flutterRoot: 'flutter/flutter', + logger: logger, + userMessages: UserMessages(), + platform: FakePlatform(environment: {}), + ); + + expect( + await localEngineLocator.findEnginePath(null, localEngine.path, null), + matchesEngineBuildPaths( + hostEngine: '/arbitrary/engine/src/out/host_debug_unopt_arm64', + targetEngine: '/arbitrary/engine/src/out/host_debug_unopt_arm64', + ), + ); + }); + testWithoutContext('fails if host_debug does not exist', () async { final FileSystem fileSystem = MemoryFileSystem.test(); final Directory localEngine = fileSystem