Fix defects in code-coverage.gralde to generate code coverage report 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 <ftianli@amazon.com>
This commit is contained in:
Tianli Feng 2021-09-13 10:56:11 -07:00 committed by GitHub
parent aecc7bd005
commit 53d60b72b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 14 deletions

View File

@ -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()
}
}

View File

@ -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) {