Print gradle output only if test is failed
This commit is contained in:
+7
-1
@@ -143,7 +143,13 @@ abstract class BaseGradleIT {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val result = runProcess(cmd, projectDir, env)
|
val result = runProcess(cmd, projectDir, env)
|
||||||
CompiledProject(this, result.output, result.exitCode).check()
|
try {
|
||||||
|
CompiledProject(this, result.output, result.exitCode).check()
|
||||||
|
}
|
||||||
|
catch (t: Throwable) {
|
||||||
|
System.out.println(result.output)
|
||||||
|
throw t
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun CompiledProject.assertSuccessful(): CompiledProject {
|
fun CompiledProject.assertSuccessful(): CompiledProject {
|
||||||
|
|||||||
+4
-7
@@ -1,6 +1,7 @@
|
|||||||
package org.jetbrains.kotlin.gradle.util
|
package org.jetbrains.kotlin.gradle.util
|
||||||
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.io.StringWriter
|
||||||
|
|
||||||
class ProcessRunResult(
|
class ProcessRunResult(
|
||||||
private val cmd: List<String>,
|
private val cmd: List<String>,
|
||||||
@@ -16,7 +17,6 @@ Executing process was ${if (isSuccessful) "successful" else "unsuccessful"}
|
|||||||
Command: ${cmd.joinToString()}
|
Command: ${cmd.joinToString()}
|
||||||
Working directory: ${workingDir.absolutePath}
|
Working directory: ${workingDir.absolutePath}
|
||||||
Exit code: $exitCode
|
Exit code: $exitCode
|
||||||
Output: $output
|
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,14 +29,11 @@ fun runProcess(cmd: List<String>, workingDir: File, environmentVariables: Map<St
|
|||||||
|
|
||||||
val process = builder.start()
|
val process = builder.start()
|
||||||
// important to read inputStream, otherwise the process may hang on some systems
|
// important to read inputStream, otherwise the process may hang on some systems
|
||||||
val sb = StringBuilder()
|
val sw = StringWriter()
|
||||||
process.inputStream!!.bufferedReader().forEachLine {
|
process.inputStream!!.bufferedReader().copyTo(sw)
|
||||||
System.out.println(it)
|
|
||||||
sb.appendln(it)
|
|
||||||
}
|
|
||||||
val exitCode = process.waitFor()
|
val exitCode = process.waitFor()
|
||||||
|
|
||||||
return ProcessRunResult(cmd, workingDir, exitCode, sb.toString())
|
return ProcessRunResult(cmd, workingDir, exitCode, sw.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createGradleCommand(tailParameters: List<String>): List<String> {
|
fun createGradleCommand(tailParameters: List<String>): List<String> {
|
||||||
|
|||||||
Reference in New Issue
Block a user