diff --git a/test_runner/src/main/kotlin/ftl/ios/xctest/common/ParseSwiftTests.kt b/test_runner/src/main/kotlin/ftl/ios/xctest/common/ParseSwiftTests.kt index 6bd32e4114..3f979cb9ad 100644 --- a/test_runner/src/main/kotlin/ftl/ios/xctest/common/ParseSwiftTests.kt +++ b/test_runner/src/main/kotlin/ftl/ios/xctest/common/ParseSwiftTests.kt @@ -5,6 +5,7 @@ import flank.common.isLinux import flank.common.isMacOS import flank.common.isWindows import ftl.util.Bash +import ftl.util.ShellEnvironment internal fun parseSwiftTests(binary: String): List { installBinaries @@ -28,7 +29,9 @@ internal fun parseSwiftTests(binary: String): List { } else emptyList() // https://github.com/linkedin/bluepill/blob/37e7efa42472222b81adaa0e88f2bd82aa289b44/Source/Shared/BPXCTestFile.m#L17-18 - val demangledOutput = Bash.execute(cmd, path) + val shell = if (isWindows) ShellEnvironment.Cmd else ShellEnvironment.Default + + val demangledOutput = Bash.execute(cmd, path, shell) demangledOutput.lines().forEach { line -> // _T025EarlGreyExampleTestsSwift0abceD0C10testLayoutyyF ---> EarlGreyExampleTestsSwift.EarlGreyExampleSwiftTests.testLayout() -> () // _T025EarlGreyExampleTestsSwift0abceD0C16testCustomActionyyF ---> EarlGreyExampleTestsSwift.EarlGreyExampleSwiftTests.testCustomAction() -> () diff --git a/test_runner/src/main/kotlin/ftl/util/Bash.kt b/test_runner/src/main/kotlin/ftl/util/Bash.kt index d6ab67a0a2..2cfec82081 100644 --- a/test_runner/src/main/kotlin/ftl/util/Bash.kt +++ b/test_runner/src/main/kotlin/ftl/util/Bash.kt @@ -6,13 +6,13 @@ import ftl.run.exception.FlankGeneralError import java.lang.ProcessBuilder.Redirect.PIPE object Bash { - - fun execute(cmd: String, additionalPath: List> = emptyList()): String { + fun execute( + cmd: String, + additionalPath: List> = emptyList(), + shellEnvironment: ShellEnvironment = ShellEnvironment.Default + ): String { logLn(cmd) - - val bashPath = if (isWindows) "bash.exe" else "/bin/bash" - - val process = ProcessBuilder(bashPath, "-c", cmd).also { + val process = ProcessBuilder(shellEnvironment.execution, "-c", cmd).also { if (additionalPath.isNotEmpty()) { val envs: MutableMap = it.environment() additionalPath.forEach { extra -> @@ -31,3 +31,10 @@ object Bash { return result.stdout.trim() + result.stderr.trim() } } + +sealed class ShellEnvironment(val execution: String) { + object Bash : ShellEnvironment("Bash.exe") + object BinBash : ShellEnvironment("/bin/bash") + object Cmd : ShellEnvironment("cmd.exe") + object Default : ShellEnvironment(if (isWindows) Bash.execution else BinBash.execution) +}