diff options
Diffstat (limited to 'integration-tests/cli/src/main/kotlin')
-rw-r--r-- | integration-tests/cli/src/main/kotlin/org/jetbrains/dokka/it/cli/processUtils.kt | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/integration-tests/cli/src/main/kotlin/org/jetbrains/dokka/it/cli/processUtils.kt b/integration-tests/cli/src/main/kotlin/org/jetbrains/dokka/it/cli/processUtils.kt deleted file mode 100644 index d2fa3b31..00000000 --- a/integration-tests/cli/src/main/kotlin/org/jetbrains/dokka/it/cli/processUtils.kt +++ /dev/null @@ -1,51 +0,0 @@ -package org.jetbrains.dokka.it.cli - -import kotlinx.coroutines.CompletableDeferred -import kotlinx.coroutines.async -import kotlinx.coroutines.runBlocking -import kotlin.concurrent.thread - -class ProcessResult( - val exitCode: Int, - val output: String -) - -fun Process.awaitProcessResult() = runBlocking { - val exitCode = async { awaitExitCode() } - val output = async { awaitOutput() } - ProcessResult( - exitCode.await(), - output.await() - ) -} - -private suspend fun Process.awaitExitCode(): Int { - val deferred = CompletableDeferred<Int>() - thread { - try { - deferred.complete(this.waitFor()) - } catch (e: Throwable) { - deferred.completeExceptionally(e) - } - } - - return deferred.await() -} - -private suspend fun Process.awaitOutput(): String { - val deferred = CompletableDeferred<String>() - thread { - try { - var string = "" - this.inputStream.bufferedReader().forEachLine { line -> - println(line) - string += line + System.lineSeparator() - } - deferred.complete(string) - } catch (e: Throwable) { - deferred.completeExceptionally(e) - } - } - - return deferred.await() -} |