diff --git a/packages/flutter_tools/lib/src/runner/local_engine.dart b/packages/flutter_tools/lib/src/runner/local_engine.dart index f3944b5bab..e5911f2c2d 100644 --- a/packages/flutter_tools/lib/src/runner/local_engine.dart +++ b/packages/flutter_tools/lib/src/runner/local_engine.dart @@ -157,7 +157,7 @@ class LocalEngineLocator { } // Determine the host engine directory associated with the local engine: - // Strip '_sim_' since there are no host simulator builds. + // Strip '_sim' since there are no host simulator builds. String _getHostEngineBasename(String localEngineBasename) { if (localEngineBasename.startsWith('web_') || localEngineBasename.startsWith('wasm_') || @@ -166,7 +166,7 @@ class LocalEngineLocator { return localEngineBasename; } - String tmpBasename = localEngineBasename.replaceFirst('_sim_', '_'); + String tmpBasename = localEngineBasename.replaceFirst('_sim', ''); tmpBasename = tmpBasename.substring(tmpBasename.indexOf('_') + 1); // Strip suffix for various archs. const List suffixes = ['_arm', '_arm64', '_x86', '_x64']; 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 fc62a97c90..2845922dcf 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 @@ -170,6 +170,61 @@ void main() { ); }); + testWithoutContext('works if local engine is simulator', () async { + final FileSystem fileSystem = MemoryFileSystem.test(); + final Directory localEngine = fileSystem + .directory('$kArbitraryEngineRoot/src/out/ios_debug_sim/') + ..createSync(recursive: true); + fileSystem + .directory('$kArbitraryEngineRoot/src/out/host_debug/') + .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(localEngine: localEngine.path), + matchesEngineBuildPaths( + hostEngine: '/arbitrary/engine/src/out/host_debug', + targetEngine: '/arbitrary/engine/src/out/ios_debug_sim', + ), + ); + }); + + testWithoutContext('works if local engine is simulator unoptimized', + () async { + final FileSystem fileSystem = MemoryFileSystem.test(); + final Directory localEngine = fileSystem + .directory('$kArbitraryEngineRoot/src/out/ios_debug_sim_unopt/') + ..createSync(recursive: true); + fileSystem + .directory('$kArbitraryEngineRoot/src/out/host_debug_unopt/') + .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(localEngine: localEngine.path), + matchesEngineBuildPaths( + hostEngine: '/arbitrary/engine/src/out/host_debug_unopt', + targetEngine: '/arbitrary/engine/src/out/ios_debug_sim_unopt', + ), + ); + }); + testWithoutContext('fails if host_debug does not exist', () async { final FileSystem fileSystem = MemoryFileSystem.test(); final Directory localEngine = fileSystem