Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix part of #5343: Building proto with coverage results for data proc…
…essing (#5439) <!-- READ ME FIRST: Please fill in the explanation section below and check off every point from the Essential Checklist! --> ## Explanation <!-- - Explain what your PR does. If this PR fixes an existing bug, please include - "Fixes #bugnum:" in the explanation so that GitHub can auto-close the issue - when this PR is merged. --> Fixes part of #5343 ### Project [PR 1.4 of Project 4.1] ### Changes Made - Introduced `coverage.proto` to store the coverage data generated during coverage analysis. - Parsed coverage data according to the LCOV (geninfo) file format specifications: [LCOV geninfo specifications](https://manpages.debian.org/stretch/lcov/geninfo.1.en.html#FILES) - This maps the Bazel test target to the corresponding SF: source file path and filters the data to generate the Coverage Report proto that will only the coverage of the tests related to the single source file. - With the previous implementation in PR 1.3 to get the related LocalTest and Test file mappings, we utilize that to run coverage for both the test and return them as a list of Coverage Report protos. **To Note:** - Only the app module has the multi test file case. - But as of date, the many app module coverage executions fail. - So to test acquiring multi test coverage execution as list of Coverage Report Proto, I hardcoded and tested the implementation [[hardcoded comment](https://github.com/oppia/oppia-android/pull/5439/files#diff-62c81482e7c4b720da2d4efc73a48d10369eee097e0bf3439def6648ff150c23R89-R93)] (just for testing the actual code wouldn't have that) **Result:** A representation of the list of Coverage Report proto is presented below: This is the output on running 2 hardcoded test cases: `math:MathModelTest` and `math:FloatExtensionsTest` <details> <summary>List of Coverage Report</summary> <br> <pre> Parsed Coverage Data File: /home/rddev/.../bazel-out/.../util/parser/math/MathModelTest/coverage.dat Parsed Coverage Data File: /home/rddev/.../bazel-out/.../util/math/FloatExtensionsTest/coverage.dat Coverage Data List: [bazel_test_target: "//utility/src/test/java/org/oppia/android/util/parser/math:MathModelTest" covered_file { file_path: "utility/src/main/java/org/oppia/android/util/parser/math/MathModel.kt" file_sha1_hash: "37eb0c6a3a16c300da100e245e7d320c61cc008f" covered_line { line_number: 14 coverage: FULL } covered_line { line_number: 15 coverage: FULL } covered_line { line_number: 16 coverage: FULL } covered_line { line_number: 17 coverage: FULL } covered_line { line_number: 21 coverage: FULL } covered_line { line_number: 33 coverage: FULL } covered_line { line_number: 34 coverage: FULL } covered_line { line_number: 35 coverage: FULL } covered_line { line_number: 36 coverage: FULL } covered_line { line_number: 41 coverage: FULL } covered_line { line_number: 42 coverage: FULL } covered_line { line_number: 43 coverage: FULL } covered_line { line_number: 44 coverage: FULL } covered_line { line_number: 45 coverage: FULL } covered_line { line_number: 46 coverage: FULL } covered_line { line_number: 47 coverage: FULL } covered_line { line_number: 49 coverage: FULL } covered_line { line_number: 58 coverage: FULL } covered_line { line_number: 59 coverage: FULL } lines_found: 19 lines_hit: 19 function_coverage { line_number: 58 function_name: "org/oppia/android/util/parser/math/MathModel$MathModelSignature$Companion::createSignature$utility_src_main_java_org_oppia_android_util_parser_math_math_latex_model_kt (Ljava/lang/String;FZ)Lorg/oppia/android/util/parser/math/MathModel$MathModelSignature;" execution_count: 1 coverage: FULL } function_coverage { line_number: 33 function_name: "org/oppia/android/util/parser/math/MathModel$MathModelSignature::<init> (Ljava/lang/String;IZ)V" execution_count: 1 coverage: FULL } function_coverage { line_number: 35 function_name: "org/oppia/android/util/parser/math/MathModel$MathModelSignature::getLineHeightHundredX ()I" execution_count: 1 coverage: FULL } function_coverage { line_number: 34 function_name: "org/oppia/android/util/parser/math/MathModel$MathModelSignature::getRawLatex ()Ljava/lang/String;" execution_count: 0 coverage: NONE } function_coverage { line_number: 36 function_name: "org/oppia/android/util/parser/math/MathModel$MathModelSignature::getUseInlineRendering ()Z" execution_count: 1 coverage: FULL } function_coverage { line_number: 41 function_name: "org/oppia/android/util/parser/math/MathModel$MathModelSignature::updateDiskCacheKey (Ljava/security/MessageDigest;)V" execution_count: 1 coverage: FULL } function_coverage { line_number: 14 function_name: "org/oppia/android/util/parser/math/MathModel::<init> (Ljava/lang/String;FZ)V" execution_count: 1 coverage: FULL } function_coverage { line_number: 16 function_name: "org/oppia/android/util/parser/math/MathModel::getLineHeight ()F" execution_count: 0 coverage: NONE } function_coverage { line_number: 15 function_name: "org/oppia/android/util/parser/math/MathModel::getRawLatex ()Ljava/lang/String;" execution_count: 0 coverage: NONE } function_coverage { line_number: 17 function_name: "org/oppia/android/util/parser/math/MathModel::getUseInlineRendering ()Z" execution_count: 0 coverage: NONE } function_coverage { line_number: 21 function_name: "org/oppia/android/util/parser/math/MathModel::toKeySignature ()Lorg/oppia/android/util/parser/math/MathModel$MathModelSignature;" execution_count: 1 coverage: FULL } functions_found: 11 functions_hit: 7 branch_coverage { line_number: 46 block_number: 0 branch_number: 0 hit_count: 1 coverage: FULL } branch_coverage { line_number: 46 block_number: 0 branch_number: 1 hit_count: 1 coverage: FULL } branches_found: 2 branches_hit: 2 } , bazel_test_target: "//utility/src/test/java/org/oppia/android/util/math:FloatExtensionsTest" covered_file { file_path: "utility/src/main/java/org/oppia/android/util/math/FloatExtensions.kt" file_sha1_hash: "178a2d84e9182a11b41adf34abc0a92a7d365f50" covered_line { line_number: 28 coverage: FULL } covered_line { line_number: 36 coverage: FULL } covered_line { line_number: 43 coverage: FULL } lines_found: 3 lines_hit: 3 function_coverage { line_number: 36 function_name: "org/oppia/android/util/math/FloatExtensionsKt::isApproximatelyEqualTo (DD)Z" execution_count: 1 coverage: FULL } function_coverage { line_number: 28 function_name: "org/oppia/android/util/math/FloatExtensionsKt::isApproximatelyEqualTo (FF)Z" execution_count: 1 coverage: FULL } function_coverage { line_number: 43 function_name: "org/oppia/android/util/math/FloatExtensionsKt::toPlainString (D)Ljava/lang/String;" execution_count: 1 coverage: FULL } functions_found: 3 functions_hit: 3 branch_coverage { line_number: 28 block_number: 0 branch_number: 0 hit_count: 1 coverage: FULL } branch_coverage { line_number: 28 block_number: 0 branch_number: 1 hit_count: 1 coverage: FULL } branch_coverage { line_number: 36 block_number: 0 branch_number: 0 hit_count: 1 coverage: FULL } branch_coverage { line_number: 36 block_number: 0 branch_number: 1 hit_count: 1 coverage: FULL } branches_found: 4 branches_hit: 4 } ] </pre> </details> **Representation in Protobuf** - Function Coverage: Interpreted execution counts to determine coverage status. Any execution count greater than 0 signifies full coverage, otherwise considered null. - Branch Coverage: Determined coverage based on the recorded hit count for each branch. A hit count greater than 0 denotes full coverage, otherwise marked as null. **Usage:** The stored proto will be used to generate coverage reports in **md** and **HTML** formats [to be handled in PR 1.5] ## Essential Checklist <!-- Please tick the relevant boxes by putting an "x" in them. --> - [x] The PR title and explanation each start with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".) - [x] Any changes to [scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets) files have their rationale included in the PR explanation. - [x] The PR follows the [style guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide). - [x] The PR does not contain any unnecessary code changes from Android Studio ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)). - [x] The PR is made from a branch that's **not** called "develop" and is up-to-date with "develop". - [ ] The PR is **assigned** to the appropriate reviewers ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)). ## For UI-specific PRs only <!-- Delete these section if this PR does not include UI-related changes. --> If your PR includes UI-related changes, then: - Add screenshots for portrait/landscape for both a tablet & phone of the before & after UI changes - For the screenshots above, include both English and pseudo-localized (RTL) screenshots (see [RTL guide](https://github.com/oppia/oppia-android/wiki/RTL-Guidelines)) - Add a video showing the full UX flow with a screen reader enabled (see [accessibility guide](https://github.com/oppia/oppia-android/wiki/Accessibility-A11y-Guide)) - For PRs introducing new UI elements or color changes, both light and dark mode screenshots must be included - Add a screenshot demonstrating that you ran affected Espresso tests locally & that they're passing --------- Co-authored-by: Ben Henning <[email protected]> Co-authored-by: Adhiambo Peres <[email protected]>
- Loading branch information