Gradle tests: output compiler process stdout and stderr
This commit is contained in:
+11
-7
@@ -2,6 +2,7 @@ package org.jetbrains.kotlin.gradle
|
|||||||
|
|
||||||
import com.google.common.io.Files
|
import com.google.common.io.Files
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.io.InputStream
|
||||||
import java.util.Scanner
|
import java.util.Scanner
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
@@ -76,16 +77,19 @@ open class BaseGradleIT(resourcesRoot: String = "src/test/resources") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun readOutput(process: Process): Pair<String, Int> {
|
private fun readOutput(process: Process): Pair<String, Int> {
|
||||||
val s = Scanner(process.getInputStream()!!)
|
fun InputStream.readFully(): String {
|
||||||
val text = StringBuilder()
|
val text = reader().readText()
|
||||||
while (s.hasNextLine()) {
|
close()
|
||||||
text append s.nextLine()
|
return text
|
||||||
text append "\n"
|
|
||||||
}
|
}
|
||||||
s.close()
|
|
||||||
|
val stdout = process.getInputStream()!!.readFully()
|
||||||
|
System.out.println(stdout)
|
||||||
|
val stderr = process.getErrorStream()!!.readFully()
|
||||||
|
System.err.println(stderr)
|
||||||
|
|
||||||
val result = process.waitFor()
|
val result = process.waitFor()
|
||||||
return text.toString() to result
|
return stdout to result
|
||||||
}
|
}
|
||||||
|
|
||||||
fun copyRecursively(source: File, target: File) {
|
fun copyRecursively(source: File, target: File) {
|
||||||
|
|||||||
Reference in New Issue
Block a user