Skip to content

Commit

Permalink
Update the script to align with changes in BazelClient PR 1.1 to retu…
Browse files Browse the repository at this point in the history
…rn the coverage data as a List of String
  • Loading branch information
Rd4dev committed Jun 21, 2024
1 parent 0f5cffd commit 87d34ad
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ kt_jvm_library(
visibility = ["//scripts:oppia_script_binary_visibility"],
deps = [
"//scripts/src/java/org/oppia/android/scripts/common:bazel_client",
"//scripts/src/java/org/oppia/android/scripts/proto:script_exemptions_java_proto",
"//scripts/src/java/org/oppia/android/scripts/coverage:run_coverage_for_test_target_lib",
"//scripts/src/java/org/oppia/android/scripts/proto:script_exemptions_java_proto",
],
)

Expand All @@ -40,6 +40,5 @@ kt_jvm_library(
visibility = ["//scripts:oppia_script_binary_visibility"],
deps = [
"//scripts/src/java/org/oppia/android/scripts/common:bazel_client",
"//scripts/src/java/org/oppia/android/scripts/common:git_client",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ class RunCoverage(
* a Bazel client, finds potential test file paths, retrieves Bazel targets, and initiates
* coverage analysis for each test target found.
*/
fun execute(): List<String?> {
var coverageDataList = mutableListOf<String>()
fun execute(): MutableList<List<String>> {
var coverageDataList = mutableListOf<List<String>>()
val testFileExemptionList = loadTestFileExemptionsProto(testFileExemptionTextProto)
.getExemptedFilePathList()

val isExempted = testFileExemptionList.contains(filePath)
if (isExempted) {
println("This file is exempted from having a test file. Hence No coverage!")
return emptyList()
return mutableListOf()
}

val testFilePaths = findTestFile(repoRoot, filePath)
Expand All @@ -94,6 +94,7 @@ class RunCoverage(
).runCoverage()!!
coverageDataList.add(coverageData)
}
println("Coverage Data List: $coverageDataList")
return coverageDataList
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,27 +224,29 @@ class RunCoverageTest {
scriptBgDispatcher
).execute()

val expectedResultList = listOf(
"SF:coverage/main/java/com/example/TwoSum.kt\n" +
"FN:7,com/example/TwoSum${'$'}Companion::sumNumbers (II)Ljava/lang/Object;\n" +
"FN:3,com/example/TwoSum::<init> ()V\n" +
"FNDA:1,com/example/TwoSum${'$'}Companion::sumNumbers (II)Ljava/lang/Object;\n" +
"FNDA:0,com/example/TwoSum::<init> ()V\n" +
"FNF:2\n" +
"FNH:1\n" +
"BRDA:7,0,0,1\n" +
"BRDA:7,0,1,1\n" +
"BRDA:7,0,2,1\n" +
"BRDA:7,0,3,1\n" +
"BRF:4\n" +
"BRH:4\n" +
"DA:3,0\n" +
"DA:7,1\n" +
"DA:8,1\n" +
"DA:10,1\n" +
"LH:3\n" +
"LF:4\n" +
"end_of_record\n"
val expectedResultList = mutableListOf(
listOf(
"SF:coverage/main/java/com/example/TwoSum.kt",
"FN:7,com/example/TwoSum${'$'}Companion::sumNumbers (II)Ljava/lang/Object;",
"FN:3,com/example/TwoSum::<init> ()V",
"FNDA:1,com/example/TwoSum${'$'}Companion::sumNumbers (II)Ljava/lang/Object;",
"FNDA:0,com/example/TwoSum::<init> ()V",
"FNF:2",
"FNH:1",
"BRDA:7,0,0,1",
"BRDA:7,0,1,1",
"BRDA:7,0,2,1",
"BRDA:7,0,3,1",
"BRF:4",
"BRH:4",
"DA:3,0",
"DA:7,1",
"DA:8,1",
"DA:10,1",
"LH:3",
"LF:4",
"end_of_record"
)
)

assertThat(result).isEqualTo(expectedResultList)
Expand Down

0 comments on commit 87d34ad

Please sign in to comment.