[GitHub] [lucene] rmuir commented on a change in pull request #119: LUCENE-9188: Add jacoco code coverage support to gradle
rmuir commented on a change in pull request #119: URL: https://github.com/apache/lucene/pull/119#discussion_r624472119 ## File path: gradle/testing/coverage.gradle ## @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (Boolean.parseBoolean(propertyOrDefault("tests.coverage", "false"))) { + allprojects { +apply plugin: "jacoco" +tasks.withType(Test) { + // XXX: too many things called "workingDir" in gradle! + def targetDir = "${buildDir}/tmp/tests-cwd" Review comment: let's keep the build clean. if you have improvements on this PR, just push. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org
[GitHub] [lucene] rmuir commented on a change in pull request #119: LUCENE-9188: Add jacoco code coverage support to gradle
rmuir commented on a change in pull request #119: URL: https://github.com/apache/lucene/pull/119#discussion_r624467798 ## File path: help/tests.txt ## @@ -156,6 +156,16 @@ to increase the top-N count: gradlew -p lucene/core test -Ptests.profile=true -Ptests.profile.count=100 +Generating Coverage Reports +-- + +Adding the property "tests.coverage=true" will run the tests with instrumentation to +record coverage. The "jacocoTestReport" target will generate a report from those files. + +Example: + +gradlew -p lucene/core -Ptests.coverage=true test jacocoTestReport Review comment: Well, anything making this easier to use would be great! I really wanted the help documentation to show two phases: 1. instrumented test execution (must be opt-in with some parameter) 2. report generation But it made things too confusing: e.g. say you make this mistake: ```console $ gradlew -Ptests.coverage=true test $ gradlew jacocoTestReport ``` In that case jacoco plugin is never applied and so you get a crazy error message for missing task `jacocoTestReport`. You must also add `-Ptests.coverage=true` to this secondary reporting task, or it won't work. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org
[GitHub] [lucene] rmuir commented on a change in pull request #119: LUCENE-9188: Add jacoco code coverage support to gradle
rmuir commented on a change in pull request #119: URL: https://github.com/apache/lucene/pull/119#discussion_r624457772 ## File path: gradle/testing/randomization/policies/tests.policy ## @@ -104,9 +104,16 @@ grant { permission java.io.FilePermission "${user.home}${/}.ivy2${/}cache${/}-", "read"; permission java.io.FilePermission "${junit4.tempDir}${/}*", "read,write,delete"; permission java.io.FilePermission "${clover.db.dir}${/}-", "read,write,delete"; - permission java.io.FilePermission "${junit4.childvm.cwd}${/}jacoco.db", "write"; +}; + +// Permissions for jacoco code coverage +grant { Review comment: It can work to apply permissions to jars, but only if they invoke the privileged methods using `AccessController.doPrivileged` (possibly checking their own custom permission first or something). Given that it seems openjdk plans to deprecate SecurityManager (https://openjdk.java.net/jeps/411), I wouldn't optimize our current setup any more? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org
[GitHub] [lucene] rmuir commented on a change in pull request #119: LUCENE-9188: Add jacoco code coverage support to gradle
rmuir commented on a change in pull request #119: URL: https://github.com/apache/lucene/pull/119#discussion_r624454578 ## File path: gradle/testing/coverage.gradle ## @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (Boolean.parseBoolean(propertyOrDefault("tests.coverage", "false"))) { + allprojects { +apply plugin: "jacoco" +tasks.withType(Test) { + // XXX: too many things called "workingDir" in gradle! + def targetDir = "${buildDir}/tmp/tests-cwd" Review comment: just for background, this is different than the ant build, which gave each jvm its own output file, and then explicitly merged the results across the N-jvms tests files. But I think writing to just one file is better and simpler, and it is the gradle default too. Really this is just a shutdown hook to dump the accumulated data before exiting, so it isn't like we introduce synchronization issues or performance problems. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org
[GitHub] [lucene] rmuir commented on a change in pull request #119: LUCENE-9188: Add jacoco code coverage support to gradle
rmuir commented on a change in pull request #119: URL: https://github.com/apache/lucene/pull/119#discussion_r624452579 ## File path: gradle/testing/coverage.gradle ## @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (Boolean.parseBoolean(propertyOrDefault("tests.coverage", "false"))) { + allprojects { +apply plugin: "jacoco" +tasks.withType(Test) { + // XXX: too many things called "workingDir" in gradle! + def targetDir = "${buildDir}/tmp/tests-cwd" Review comment: @dweiss one thing is the fact that jacoco runs in append-mode. We don't want to just keep accumulating coverage over unrelated `gradle test` runs. The append-only mode serves a separate purpose, that is to allow N test jvms to append to the same output database (just saves us a merging step, really) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org
[GitHub] [lucene] rmuir commented on a change in pull request #119: LUCENE-9188: Add jacoco code coverage support to gradle
rmuir commented on a change in pull request #119: URL: https://github.com/apache/lucene/pull/119#discussion_r624447305 ## File path: gradle/testing/coverage.gradle ## @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (Boolean.parseBoolean(propertyOrDefault("tests.coverage", "false"))) { + allprojects { +apply plugin: "jacoco" Review comment: I think it is built into gradle itself: https://docs.gradle.org/current/userguide/jacoco_plugin.html -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org