Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Code coverage report can't be generated properly due to defect in code-coverage.gradle #1213

Closed
tlfeng opened this issue Sep 3, 2021 · 0 comments · Fixed by #1214
Closed
Assignees
Labels
bug Something isn't working Build Libraries & Interfaces v2.0.0 Version 2.0.0

Comments

@tlfeng
Copy link
Collaborator

tlfeng commented Sep 3, 2021

Describe the bug
There are 2 bugs in code-coverage.gradle:

  1. When running ./gradlew check -Dtests.coverage=true, the following error occurs:
Suite: Test class org.opensearch.test.loggerusage.OpenSearchLoggerUsageTests
  2> java.lang.RuntimeException: unable to install test security manager
        at org.opensearch.bootstrap.BootstrapForTesting.<clinit>(BootstrapForTesting.java:190)
        at org.opensearch.test.OpenSearchTestCase.<clinit>(OpenSearchTestCase.java:251)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:468)
        at com.carrotsearch.randomizedtesting.RandomizedRunner$2.run(RandomizedRunner.java:623)

        Caused by:
        java.lang.NullPointerException: Cannot invoke "String.length()" because "input" is null
...
  1. Whether the system property "tests.coverage.html_report" is set or not, the html format code coverage report is always generated.

Reason:

  1. I used the same System property "tests.coverage" from an old code into my gradle script.
  2. html format code coverage report is generated by default by JaCoCo gralde plugin, see here

To Reproduce
Steps to reproduce the behavior:
For bug 1: run ./gradlew check -Dtests.coverage=true
For bug 2: run ./gradlew codeCoverageReportForUnitTest or ./gradlew codeCoverageReport, without having -Dtests.coverage.html_report, the code coverage report in html format is generated in /build/reports/jacoco/

Expected behavior

  1. ./gradlew check -Dtests.coverage=true can run gradle check and generate code coverage report without error.
  2. Without having tests.coverage.html_report property, html format shouldn't be generated, and only xml format is generated. Only when adding the system property tests.coverage.html_report, such as running ./gradlew codeCoverageReport -Dtests.coverage.html_report, the report in html format can be generated.

Plugins
Please list all plugins currently enabled.

Screenshots
If applicable, add screenshots to help explain your problem.

Host/Environment (please complete the following information):

  • OS: [e.g. iOS]
  • Version [e.g. 22]

Additional context
Imported by #971
Related issue: #850

@tlfeng tlfeng self-assigned this Sep 3, 2021
@tlfeng tlfeng changed the title [BUG] Code coverage report can't be generated properly due to defect in code-coverage.gradle [BUG] Code coverage report can't be generated properly due to defects in system property definition Sep 3, 2021
@tlfeng tlfeng changed the title [BUG] Code coverage report can't be generated properly due to defects in system property definition [BUG] Code coverage report can't be generated properly due to defect in code-coverage.gradle Sep 3, 2021
@tlfeng tlfeng added the v2.0.0 Version 2.0.0 label Sep 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Build Libraries & Interfaces v2.0.0 Version 2.0.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant