mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-24 16:02:55 +08:00
test(jetbrains): wait for killed child process
This commit is contained in:
+9
-1
@@ -33,7 +33,7 @@ class KiloBackendCliKillTest {
|
||||
|
||||
assertTrue(proc.waitFor(PROCESS_TIMEOUT_SECONDS, TimeUnit.SECONDS), "parent process did not exit")
|
||||
assertFalse(proc.isAlive)
|
||||
kids.forEach { child -> assertFalse(child.isAlive, "child process ${child.pid()} is still alive") }
|
||||
kids.forEach { child -> assertTrue(exited(child), "child process ${child.pid()} is still alive") }
|
||||
} finally {
|
||||
cleanup(proc)
|
||||
}
|
||||
@@ -78,6 +78,14 @@ class KiloBackendCliKillTest {
|
||||
return proc.toHandle().descendants().toList()
|
||||
}
|
||||
|
||||
private fun exited(child: ProcessHandle): Boolean {
|
||||
if (!child.isAlive) return true
|
||||
return runCatching {
|
||||
child.onExit().get(PROCESS_TIMEOUT_SECONDS, TimeUnit.SECONDS)
|
||||
true
|
||||
}.getOrDefault(!child.isAlive)
|
||||
}
|
||||
|
||||
private fun cleanup(proc: Process) {
|
||||
proc.toHandle().descendants().forEach { it.destroyForcibly() }
|
||||
proc.destroyForcibly()
|
||||
|
||||
Reference in New Issue
Block a user