Kill idb on an exception. Otherwise in case of idb failure, it may not be able to run and install next application.
This commit is contained in:
committed by
Pavel Punegov
parent
02ea97b609
commit
3169e3c857
@@ -328,50 +328,56 @@ private fun deviceLauncher(project: Project) = object : ExecutorService {
|
|||||||
private val deviceName = project.findProperty("device_name") as? String
|
private val deviceName = project.findProperty("device_name") as? String
|
||||||
|
|
||||||
override fun execute(action: Action<in ExecSpec>): ExecResult? {
|
override fun execute(action: Action<in ExecSpec>): ExecResult? {
|
||||||
val udid = targetUDID()
|
var result: ExecResult? = null
|
||||||
println("Found device UDID: $udid")
|
try {
|
||||||
install(udid, xcProject.resolve("build/KonanTestLauncher.ipa").toString())
|
val udid = targetUDID()
|
||||||
val bundleId = "org.jetbrains.kotlin.KonanTestLauncher"
|
println("Found device UDID: $udid")
|
||||||
val commands = startDebugServer(udid, bundleId)
|
install(udid, xcProject.resolve("build/KonanTestLauncher.ipa").toString())
|
||||||
.split("\n")
|
val bundleId = "org.jetbrains.kotlin.KonanTestLauncher"
|
||||||
.filter { it.isNotBlank() }
|
val commands = startDebugServer(udid, bundleId)
|
||||||
.flatMap { listOf("-o", it) }
|
.split("\n")
|
||||||
|
.filter { it.isNotBlank() }
|
||||||
|
.flatMap { listOf("-o", it) }
|
||||||
|
|
||||||
var savedOut: OutputStream? = null
|
var savedOut: OutputStream? = null
|
||||||
val out = ByteArrayOutputStream()
|
val out = ByteArrayOutputStream()
|
||||||
val result = project.exec { execSpec: ExecSpec ->
|
result = project.exec { execSpec: ExecSpec ->
|
||||||
action.execute(execSpec)
|
action.execute(execSpec)
|
||||||
execSpec.executable = "lldb"
|
execSpec.executable = "lldb"
|
||||||
execSpec.args = commands + "-b" + "-o" + "command script import ${pythonScript()}" +
|
execSpec.args = commands + "-b" + "-o" + "command script import ${pythonScript()}" +
|
||||||
"-o" + ("process launch" +
|
"-o" + ("process launch" +
|
||||||
(execSpec.args.takeUnless { it.isEmpty() }
|
(execSpec.args.takeUnless { it.isEmpty() }
|
||||||
?.let { " -- ${it.joinToString(" ")}" }
|
?.let { " -- ${it.joinToString(" ")}" }
|
||||||
?: "")) +
|
?: "")) +
|
||||||
"-o" + "get_exit_code" +
|
"-o" + "get_exit_code" +
|
||||||
"-k" + "get_exit_code" +
|
"-k" + "get_exit_code" +
|
||||||
"-k" + "exit -1"
|
"-k" + "exit -1"
|
||||||
// A test task that uses project.exec { } sets the stdOut to parse the result,
|
// A test task that uses project.exec { } sets the stdOut to parse the result,
|
||||||
// but the test executable is being run under debugger that has its own output mixed with the
|
// but the test executable is being run under debugger that has its own output mixed with the
|
||||||
// output from the test. Save the stdOut from the test to write the parsed output to it.
|
// output from the test. Save the stdOut from the test to write the parsed output to it.
|
||||||
savedOut = execSpec.standardOutput
|
savedOut = execSpec.standardOutput
|
||||||
execSpec.standardOutput = out
|
execSpec.standardOutput = out
|
||||||
}
|
}
|
||||||
out.toString()
|
out.toString()
|
||||||
.also { if (project.verboseTest) println(it) }
|
.also { if (project.verboseTest) println(it) }
|
||||||
.split("\n")
|
.split("\n")
|
||||||
.dropWhile { s -> !s.startsWith("(lldb) process launch") }
|
.dropWhile { s -> !s.startsWith("(lldb) process launch") }
|
||||||
.drop(1) // drop 'process launch' also
|
.drop(1) // drop 'process launch' also
|
||||||
.dropLastWhile { ! it.matches(".*Process [0-9]* exited with status .*".toRegex()) }
|
.dropLastWhile { !it.matches(".*Process [0-9]* exited with status .*".toRegex()) }
|
||||||
.joinToString("\n") {
|
.joinToString("\n") {
|
||||||
it.replace("Process [0-9]* exited with status .*".toRegex(), "")
|
it.replace("Process [0-9]* exited with status .*".toRegex(), "")
|
||||||
.replace("\r", "") // TODO: investigate: where does the \r comes from
|
.replace("\r", "") // TODO: investigate: where does the \r comes from
|
||||||
}
|
}
|
||||||
.also {
|
.also {
|
||||||
savedOut?.write(it.toByteArray())
|
savedOut?.write(it.toByteArray())
|
||||||
}
|
}
|
||||||
|
|
||||||
uninstall(udid, bundleId)
|
uninstall(udid, bundleId)
|
||||||
kill()
|
} catch (exc: Exception) {
|
||||||
|
throw RuntimeException("iOS-device execution failed", exc)
|
||||||
|
} finally {
|
||||||
|
kill()
|
||||||
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user