Skip to content

Commit

Permalink
fix: properly pipe the error
Browse files Browse the repository at this point in the history
  • Loading branch information
amanjeetsingh150 committed Jan 29, 2025
1 parent 05cf8d9 commit b511728
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
4 changes: 2 additions & 2 deletions maestro-ios-driver/src/main/kotlin/util/CommandLineUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object CommandLineUtils {
} else {
ProcessBuilder(*parts.toTypedArray())
.redirectOutput(nullFile)
.redirectError(nullFile)
.redirectError(ProcessBuilder.Redirect.PIPE)
}

processBuilder.environment().putAll(params)
Expand All @@ -42,7 +42,7 @@ object CommandLineUtils {
.readUtf8()

logger.error("Process failed with exit code ${process.exitValue()}")
logger.error(processOutput)
logger.error("Error output $processOutput")

throw IllegalStateException(processOutput)
}
Expand Down
25 changes: 17 additions & 8 deletions maestro-ios-driver/src/main/kotlin/util/LocalSimulatorUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,24 @@ object LocalSimulatorUtils {

fun terminate(deviceId: String, bundleId: String) {
// Ignore error return: terminate will fail if the app is not running
runCommand(
listOf(
"xcrun",
"simctl",
"terminate",
deviceId,
bundleId
logger.info("[Start] Terminating app $bundleId")
runCatching {
runCommand(
listOf(
"xcrun",
"simctl",
"terminate",
deviceId,
bundleId
)
)
)
}.onFailure {
if (it.message?.contains("found nothing to terminate") == false) {
logger.info("The bundle $bundleId is already terminated")
throw it
}
}
logger.info("[Done] Terminating app $bundleId")
}

private fun isAppRunning(deviceId: String, bundleId: String): Boolean {
Expand Down

0 comments on commit b511728

Please sign in to comment.