Skip to content

Commit

Permalink
Fix defects in code-coverage.gralde to generate code coverage report …
Browse files Browse the repository at this point in the history
…properly (#1214)

* Refactor the logic to control the format for code coverage report and rename the system property

* Remove outdated code of giving JaCoCo files permission when Java security manager enabled

Signed-off-by: Tianli Feng <[email protected]>
  • Loading branch information
Tianli Feng authored Sep 13, 2021
1 parent aecc7bd commit 53d60b7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
9 changes: 4 additions & 5 deletions gradle/code-coverage.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,10 @@ tasks.withType(JacocoReport).configureEach {
classDirectories.setFrom files(selectedProjects.sourceSets.main.output)

reports {
xml.enabled true
// Code coverage report in HTML format is on demand, since it takes up 100+MB of disk space.
if (System.getProperty('tests.coverage.html_report')) {
html.enabled true
}
// Code coverage report in HTML and CSV formats are on demand, in case they take extra disk space.
xml.enabled System.getProperty('tests.coverage.report.xml', 'true').toBoolean()
html.enabled System.getProperty('tests.coverage.report.html', 'false').toBoolean()
csv.enabled System.getProperty('tests.coverage.report.csv', 'false').toBoolean()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,6 @@ public class BootstrapForTesting {
if (Strings.hasLength(System.getProperty("tests.config"))) {
FilePermissionUtils.addSingleFilePath(perms, PathUtils.get(System.getProperty("tests.config")), "read,readlink");
}
// jacoco coverage output file
final boolean testsCoverage =
Booleans.parseBoolean(System.getProperty("tests.coverage", "false"));
if (testsCoverage) {
Path coverageDir = PathUtils.get(System.getProperty("tests.coverage.dir"));
FilePermissionUtils.addSingleFilePath(perms, coverageDir.resolve("jacoco.exec"), "read,write");
// in case we get fancy and use the -integration goals later:
FilePermissionUtils.addSingleFilePath(perms, coverageDir.resolve("jacoco-it.exec"), "read,write");
}
// intellij hack: intellij test runner wants setIO and will
// screw up all test logging without it!
if (System.getProperty("tests.gradle") == null) {
Expand Down

0 comments on commit 53d60b7

Please sign in to comment.