[Test] Properly handle output from separate jvm instance in box tests

This commit is contained in:
Dmitriy Novozhilov
2021-08-05 11:41:12 +03:00
committed by teamcityserver
parent 13b5f87f3a
commit c8386ad1c7
@@ -210,12 +210,23 @@ class JvmBoxRunner(testServices: TestServices) : JvmBinaryArtifactHandler(testSe
classPath.joinToString(File.pathSeparator, transform = { File(it.toURI()).absolutePath }),
mainFqName,
)
val process = ProcessBuilder(command).inheritIO().start()
val process = ProcessBuilder(command).start()
process.waitFor(1, TimeUnit.MINUTES)
process.outputStream.flush()
return when (process.exitValue()) {
0 -> "OK"
else -> "External process completed with error. Check the build log"
return try {
when (process.exitValue()) {
0 -> "OK"
else -> buildString {
for (stream in listOfNotNull(process.inputStream, process.errorStream)) {
stream.bufferedReader().lines().forEach { appendLine(it) }
}
if (this.isEmpty()) {
appendLine("External process completed with error. Check the build log")
}
}
}
} finally {
process.outputStream.flush()
}
}