Check exit code when running compiled binary in coverage tests
This commit is contained in:
committed by
SvyatoslavScherbina
parent
6cb0175719
commit
3c548d370e
@@ -73,6 +73,7 @@ open class CoverageTest : DefaultTask() {
|
|||||||
val suffix = target.family.exeSuffix
|
val suffix = target.family.exeSuffix
|
||||||
val pathToBinary = "$outputDir/$binaryName/$target/$binaryName.$suffix"
|
val pathToBinary = "$outputDir/$binaryName/$target/$binaryName.$suffix"
|
||||||
runProcess(localExecutor(project), pathToBinary)
|
runProcess(localExecutor(project), pathToBinary)
|
||||||
|
.ensureSuccessful(pathToBinary)
|
||||||
exec("llvm-profdata", "merge", profrawFile, "-o", profdataFile)
|
exec("llvm-profdata", "merge", profrawFile, "-o", profdataFile)
|
||||||
val llvmCovResult = exec("llvm-cov", "export", pathToBinary, "-instr-profile", profdataFile)
|
val llvmCovResult = exec("llvm-cov", "export", pathToBinary, "-instr-profile", profdataFile)
|
||||||
val jsonReport = llvmCovResult.stdOut
|
val jsonReport = llvmCovResult.stdOut
|
||||||
@@ -93,19 +94,23 @@ open class CoverageTest : DefaultTask() {
|
|||||||
private fun exec(llvmTool: String, vararg args: String): ProcessOutput {
|
private fun exec(llvmTool: String, vararg args: String): ProcessOutput {
|
||||||
val executable = "$llvmToolsDir/$llvmTool"
|
val executable = "$llvmToolsDir/$llvmTool"
|
||||||
val result = runProcess(localExecutor(project), executable, args.toList())
|
val result = runProcess(localExecutor(project), executable, args.toList())
|
||||||
if (result.exitCode != 0) {
|
result.ensureSuccessful(llvmTool)
|
||||||
println("""
|
|
||||||
$llvmTool failed.
|
|
||||||
exitCode: ${result.exitCode}
|
|
||||||
stdout:
|
|
||||||
${result.stdOut}
|
|
||||||
stderr:
|
|
||||||
${result.stdErr}
|
|
||||||
""".trimIndent())
|
|
||||||
error("$llvmTool failed")
|
|
||||||
}
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun ProcessOutput.ensureSuccessful(executable: String) {
|
||||||
|
if (exitCode != 0) {
|
||||||
|
println("""
|
||||||
|
$executable failed.
|
||||||
|
exitCode: $exitCode
|
||||||
|
stdout:
|
||||||
|
$stdOut
|
||||||
|
stderr:
|
||||||
|
$stdErr
|
||||||
|
""".trimIndent())
|
||||||
|
error("$executable failed")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CoverageValidator(
|
private class CoverageValidator(
|
||||||
|
|||||||
Reference in New Issue
Block a user