Skip to content

Commit

Permalink
Added the reference note to the file exemptions list
Browse files Browse the repository at this point in the history
The thing left to do is converting the list to a table as per demo suggestions
  • Loading branch information
Rd4dev committed Aug 12, 2024
1 parent 6e960ee commit 292a4e9
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ class CoverageReporter(
?.takeIf { it.isNotEmpty() }
?.let { getFilenameAsDetailsSummary(it) }
?: failure.bazelTestTarget
"| $failurePath | ${failure.failureMessage} |"
"| $failurePath | ${failure.failureMessage} | :x: |"
}
}.joinToString(separator = "\n")

Expand Down Expand Up @@ -392,8 +392,8 @@ class CoverageReporter(
if (failureTableRows.isNotEmpty()) {
append("\n\n")
append("### Failure Cases\n\n")
append("| File | Failure Reason |\n")
append("|------|----------------|\n")
append("| File | Failure Reason | Status |\n")
append("|------|----------------|--------|\n")
append(failureTableRows)
}
}
Expand Down Expand Up @@ -463,11 +463,17 @@ class CoverageReporter(
} else ""

val testFileExemptedSection = buildString {
val exemptionsReferenceNote = ">Refer [test_file_exemptions.textproto]" +
"(https://github.com/oppia/oppia-android/blob/develop/" +
"scripts/assets/test_file_exemptions.textproto) for the comprehensive " +
"list of file exemptions and their required coverage percentages."
if (testFileExemptedCasesList.isNotEmpty()) {
append("\n\n")
append("### Exempted coverage\n")
append("<details><summary>Files exempted from coverage</summary> <br>")
append(testFileExemptedCasesList)
append("\n\n")
append(exemptionsReferenceNote)
append("</details>")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ class RunCoverageTest {
append("Coverage Analysis: **FAIL** :x:\n")
append("##\n\n")
append("### Failure Cases\n\n")
append("| File | Failure Reason |\n")
append("|------|----------------|\n")
append("| ${getFilenameAsDetailsSummary(sampleFile)} | $failureMessage |")
append("| File | Failure Reason | Status |\n")
append("|------|----------------|--------|\n")
append("| ${getFilenameAsDetailsSummary(sampleFile)} | $failureMessage | :x: |")
}

assertThat(readFinalMdReport()).isEqualTo(expectedMarkdown)
Expand Down Expand Up @@ -191,6 +191,10 @@ class RunCoverageTest {
val exemptedFile = "TestExempted.kt"
val exemptedFilePathList = listOf(exemptedFile)
val additionalData = "This file is exempted from having a test file; skipping coverage check."
val exemptionsReferenceNote = ">Refer [test_file_exemptions.textproto]" +
"(https://github.com/oppia/oppia-android/blob/develop/" +
"scripts/assets/test_file_exemptions.textproto) for the comprehensive " +
"list of file exemptions and their required coverage percentages."

val testFileExemption = TestFileExemptions.TestFileExemption.newBuilder().apply {
this.exemptedFilePath = exemptedFile
Expand Down Expand Up @@ -219,6 +223,8 @@ class RunCoverageTest {
append("### Exempted coverage\n")
append("<details><summary>Files exempted from coverage</summary> <br>")
append("${getFilenameAsDetailsSummary(exemptedFile, additionalData)}")
append("\n\n")
append(exemptionsReferenceNote)
append("</details>")
}

Expand All @@ -231,6 +237,10 @@ class RunCoverageTest {
val exemptedFilePathList = listOf(exemptedFile)
val additionalData = "This file is incompatible with code coverage tooling; " +
"skipping coverage check."
val exemptionsReferenceNote = ">Refer [test_file_exemptions.textproto]" +
"(https://github.com/oppia/oppia-android/blob/develop/" +
"scripts/assets/test_file_exemptions.textproto) for the comprehensive " +
"list of file exemptions and their required coverage percentages."

val testFileExemption = TestFileExemptions.TestFileExemption.newBuilder().apply {
this.exemptedFilePath = exemptedFile
Expand Down Expand Up @@ -259,6 +269,8 @@ class RunCoverageTest {
append("### Exempted coverage\n")
append("<details><summary>Files exempted from coverage</summary> <br>")
append("${getFilenameAsDetailsSummary(exemptedFile, additionalData)}")
append("\n\n")
append(exemptionsReferenceNote)
append("</details>")
}

Expand Down Expand Up @@ -364,9 +376,9 @@ class RunCoverageTest {
append("Coverage Analysis: **FAIL** :x:\n")
append("##\n\n")
append("### Failure Cases\n\n")
append("| File | Failure Reason |\n")
append("|------|----------------|\n")
append("| //coverage/example:AddNumsTest | $failureMessage |")
append("| File | Failure Reason | Status |\n")
append("|------|----------------|--------|\n")
append("| //coverage/example:AddNumsTest | $failureMessage | :x: |")
}

assertThat(readFinalMdReport()).isEqualTo(expectedMarkdown)
Expand Down Expand Up @@ -448,9 +460,9 @@ class RunCoverageTest {
append("Coverage Analysis: **FAIL** :x:\n")
append("##\n\n")
append("### Failure Cases\n\n")
append("| File | Failure Reason |\n")
append("|------|----------------|\n")
append("| //coverage/test/java/com/example:SubNumsTest | $failureMessage |")
append("| File | Failure Reason | Status |\n")
append("|------|----------------|--------|\n")
append("| //coverage/test/java/com/example:SubNumsTest | $failureMessage | :x: |")
}

assertThat(readFinalMdReport()).isEqualTo(expectedMarkdown)
Expand Down Expand Up @@ -1081,6 +1093,11 @@ class RunCoverageTest {
fun testRunCoverage_withSuccessAndExemptedFiles_generatesFinalCoverageReport() {
val exemptedFile = "TestExempted.kt"
val additionalData = "This file is exempted from having a test file; skipping coverage check."
val exemptionsReferenceNote = ">Refer [test_file_exemptions.textproto]" +
"(https://github.com/oppia/oppia-android/blob/develop/" +
"scripts/assets/test_file_exemptions.textproto) for the comprehensive " +
"list of file exemptions and their required coverage percentages."

val filePathList = listOf(
"coverage/main/java/com/example/AddNums.kt",
exemptedFile
Expand Down Expand Up @@ -1135,6 +1152,8 @@ class RunCoverageTest {
append(
"${getFilenameAsDetailsSummary(filePathList.get(1), additionalData)}"
)
append("\n\n")
append(exemptionsReferenceNote)
append("</details>")
}

Expand All @@ -1145,6 +1164,11 @@ class RunCoverageTest {
fun testRunCoverage_withFailureAndExemptedFiles_generatesFinalCoverageReport() {
val exemptedFile = "TestExempted.kt"
val additionalData = "This file is exempted from having a test file; skipping coverage check."
val exemptionsReferenceNote = ">Refer [test_file_exemptions.textproto]" +
"(https://github.com/oppia/oppia-android/blob/develop/" +
"scripts/assets/test_file_exemptions.textproto) for the comprehensive " +
"list of file exemptions and their required coverage percentages."

val filePathList = listOf(
"coverage/main/java/com/example/LowTestNums.kt",
exemptedFile
Expand Down Expand Up @@ -1201,6 +1225,8 @@ class RunCoverageTest {
append("### Exempted coverage\n")
append("<details><summary>Files exempted from coverage</summary> <br>")
append("${getFilenameAsDetailsSummary(filePathList.get(1), additionalData)}")
append("\n\n")
append(exemptionsReferenceNote)
append("</details>")
}

Expand All @@ -1211,6 +1237,11 @@ class RunCoverageTest {
fun testRunCoverage_withSuccessFailureAndExemptedFiles_generatesFinalCoverageReport() {
val exemptedFile = "TestExempted.kt"
val additionalData = "This file is exempted from having a test file; skipping coverage check."
val exemptionsReferenceNote = ">Refer [test_file_exemptions.textproto]" +
"(https://github.com/oppia/oppia-android/blob/develop/" +
"scripts/assets/test_file_exemptions.textproto) for the comprehensive " +
"list of file exemptions and their required coverage percentages."

val filePathList = listOf(
"coverage/main/java/com/example/AddNums.kt",
"coverage/main/java/com/example/LowTestNums.kt",
Expand Down Expand Up @@ -1286,6 +1317,8 @@ class RunCoverageTest {
append("### Exempted coverage\n")
append("<details><summary>Files exempted from coverage</summary> <br>")
append("${getFilenameAsDetailsSummary(filePathList.get(2), additionalData)}")
append("\n\n")
append(exemptionsReferenceNote)
append("</details>")
}

Expand All @@ -1296,6 +1329,11 @@ class RunCoverageTest {
fun testRunCoverage_withSuccessFailureMissingTestAndExemptedFiles_generatesFinalReport() {
val exemptedFile = "TestExempted.kt"
val additionalData = "This file is exempted from having a test file; skipping coverage check."
val exemptionsReferenceNote = ">Refer [test_file_exemptions.textproto]" +
"(https://github.com/oppia/oppia-android/blob/develop/" +
"scripts/assets/test_file_exemptions.textproto) for the comprehensive " +
"list of file exemptions and their required coverage percentages."

val filePathList = listOf(
"coverage/main/java/com/example/AddNums.kt",
"coverage/main/java/com/example/LowTestNums.kt",
Expand Down Expand Up @@ -1358,9 +1396,9 @@ class RunCoverageTest {
append("Coverage Analysis: **FAIL** :x:\n")
append("##\n\n")
append("### Failure Cases\n\n")
append("| File | Failure Reason |\n")
append("|------|----------------|\n")
append("| ${getFilenameAsDetailsSummary("file.kt")} | $failureMessage |\n\n")
append("| File | Failure Reason | Status |\n")
append("|------|----------------|--------|\n")
append("| ${getFilenameAsDetailsSummary("file.kt")} | $failureMessage | :x: |\n\n")
append("### Failing coverage\n\n")
append("| File | Coverage | Lines Hit | Status | Min Required |\n")
append("|------|:--------:|----------:|:------:|:------------:|\n")
Expand All @@ -1381,6 +1419,8 @@ class RunCoverageTest {
append("### Exempted coverage\n")
append("<details><summary>Files exempted from coverage</summary> <br>")
append("${getFilenameAsDetailsSummary(filePathList.get(2), additionalData)}")
append("\n\n")
append(exemptionsReferenceNote)
append("</details>")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ class CoverageReporterTest {
append("Coverage Analysis: **FAIL** :x:\n")
append("##\n\n")
append("### Failure Cases\n\n")
append("| File | Failure Reason |\n")
append("|------|----------------|\n")
append("| ://bazelTestTarget | Failure Message |")
append("| File | Failure Reason | Status |\n")
append("|------|----------------|--------|\n")
append("| ://bazelTestTarget | Failure Message | :x: |")
}

assertThat(readFinalMdReport()).isEqualTo(expectedMarkdown)
Expand All @@ -161,6 +161,11 @@ class CoverageReporterTest {
fun testGenerateMarkDownReport_withTestFileExemptionCoverageReport_generatesMarkdownTable() {
val testExemptedFilePath = "TestExempted.kt"
val additionalData = "This file is exempted from having a test file; skipping coverage check."
val exemptionsReferenceNote = ">Refer [test_file_exemptions.textproto]" +
"(https://github.com/oppia/oppia-android/blob/develop/" +
"scripts/assets/test_file_exemptions.textproto) for the comprehensive " +
"list of file exemptions and their required coverage percentages."

val testFileExemption = TestFileExemptions.TestFileExemption.newBuilder().apply {
this.exemptedFilePath = testExemptedFilePath
this.testFileNotRequired = true
Expand Down Expand Up @@ -198,6 +203,8 @@ class CoverageReporterTest {
append("### Exempted coverage\n")
append("<details><summary>Files exempted from coverage</summary> <br>")
append("${getFilenameAsDetailsSummary(testExemptedFilePath, additionalData)}")
append("\n\n")
append(exemptionsReferenceNote)
append("</details>")
}

Expand All @@ -209,6 +216,11 @@ class CoverageReporterTest {
val testExemptedFilePath = "TestExempted.kt"
val additionalData = "This file is incompatible with code coverage tooling; " +
"skipping coverage check."
val exemptionsReferenceNote = ">Refer [test_file_exemptions.textproto]" +
"(https://github.com/oppia/oppia-android/blob/develop/" +
"scripts/assets/test_file_exemptions.textproto) for the comprehensive " +
"list of file exemptions and their required coverage percentages."

val testFileExemption = TestFileExemptions.TestFileExemption.newBuilder().apply {
this.exemptedFilePath = testExemptedFilePath
this.testFileNotRequired = true
Expand Down Expand Up @@ -246,6 +258,8 @@ class CoverageReporterTest {
append("### Exempted coverage\n")
append("<details><summary>Files exempted from coverage</summary> <br>")
append("${getFilenameAsDetailsSummary(testExemptedFilePath, additionalData)}")
append("\n\n")
append(exemptionsReferenceNote)
append("</details>")
}

Expand Down Expand Up @@ -365,6 +379,10 @@ class CoverageReporterTest {
val failureFileName = "SampleFailureFile.kt"
val testExemptedFilePath = "TestExempted.kt"
val additionalData = "This file is exempted from having a test file; skipping coverage check."
val exemptionsReferenceNote = ">Refer [test_file_exemptions.textproto]" +
"(https://github.com/oppia/oppia-android/blob/develop/" +
"scripts/assets/test_file_exemptions.textproto) for the comprehensive " +
"list of file exemptions and their required coverage percentages."

val testFileExemption = TestFileExemptions.TestFileExemption.newBuilder().apply {
this.exemptedFilePath = testExemptedFilePath
Expand Down Expand Up @@ -430,9 +448,9 @@ class CoverageReporterTest {
append("Coverage Analysis: **FAIL** :x:\n")
append("##\n\n")
append("### Failure Cases\n\n")
append("| File | Failure Reason |\n")
append("|------|----------------|\n")
append("| ://bazelTestTarget | Failure Message |\n\n")
append("| File | Failure Reason | Status |\n")
append("|------|----------------|--------|\n")
append("| ://bazelTestTarget | Failure Message | :x: |\n\n")
append("### Failing coverage\n\n")
append("| File | Coverage | Lines Hit | Status | Min Required |\n")
append("|------|:--------:|----------:|:------:|:------------:|\n")
Expand All @@ -453,6 +471,8 @@ class CoverageReporterTest {
append("### Exempted coverage\n")
append("<details><summary>Files exempted from coverage</summary> <br>")
append("${getFilenameAsDetailsSummary(testExemptedFilePath, additionalData)}")
append("\n\n")
append(exemptionsReferenceNote)
append("</details>")
}

Expand Down Expand Up @@ -901,9 +921,9 @@ class CoverageReporterTest {
append("Coverage Analysis: **FAIL** :x:\n")
append("##\n\n")
append("### Failure Cases\n\n")
append("| File | Failure Reason |\n")
append("|------|----------------|\n")
append("| //:coverageReport | Failure Message |\n")
append("| File | Failure Reason | Status |\n")
append("|------|----------------|--------|\n")
append("| //:coverageReport | Failure Message | :x: |\n")
append("### Passing coverage\n\n")
append("<details>\n")
append("<summary>Files with passing code coverage</summary><br>\n\n")
Expand Down

0 comments on commit 292a4e9

Please sign in to comment.