Skip to content

Commit

Permalink
Temporary reference point for handling multiple shard coverage data
Browse files Browse the repository at this point in the history
This will be later removed. Using lcov's merge mechanism combines every data even that are not relavant to the source file making it un reliable, another option would be to manually merge them which would again turn complicated when dealing with branch and function data on scale
  • Loading branch information
Rd4dev committed Jul 22, 2024
1 parent 5ea0739 commit b266e48
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions scripts/src/java/org/oppia/android/scripts/common/BazelClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,31 @@ class BazelClient(private val rootDirectory: File, private val commandExecutor:
"Coverage command output lines " +
"with bazel tests --collect coverage: $coverageCommandOutputLines"
)

val regex = """(.*/shard_\d+_of_\d+/coverage\.dat)""".toRegex()
val shardCoveragePaths = coverageCommandOutputLines
.flatMap { regex.findAll(it).map { matchResult ->
matchResult.value.trim()
}
}

println("Shard coverage path: $shardCoveragePaths")

val lcovCommand = buildString {
append("lcov ")
shardCoveragePaths.forEach { path ->
append("--add-tracefile $path ")
}
append("--output-file ${rootDirectory}/coverage_reports/lcov_combined.dat")
}

val process = ProcessBuilder(*lcovCommand.split(" ").toTypedArray())
.redirectErrorStream(true)
.start()

val output = process.inputStream.bufferedReader().readText()
println("Output: $output")

return File(rootDirectory, "/bazel-out/_coverage/_coverage_report.dat").readLines()
} else {
println("In does not have Shard count")
Expand Down

0 comments on commit b266e48

Please sign in to comment.