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

Java coverage fixes #3253

Merged
merged 3 commits into from
Dec 11, 2024
Merged

Java coverage fixes #3253

merged 3 commits into from
Dec 11, 2024

Conversation

externl
Copy link
Member

@externl externl commented Dec 10, 2024

This PR updates the coverage generation for Java (and adds a workflow schedule). I moved the coverage logic into a bash script because it's a little complicated and somebody might want to run it locally.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 2 out of 3 changed files in this pull request and generated no suggestions.

Files not reviewed (1)
  • scripts/generate-java-code-coverage.sh: Language not supported
@@ -17,18 +19,18 @@ jobs:

- name: Generate C++ Coverage
working-directory: ./cpp
run: ../scripts/generate-code-coverage.sh
run: ../scripts/generate-cpp-code-coverage.sh
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed this file.

done

java -jar org.jacoco.cli-0.8.12-nodeps.jar report $(find . -name \*.jacoco.exec) $args --html coverage
../scripts/generate-java-code-coverage.sh
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script does the build as well, like C++

python3 allTests.py --all --workers=4 --debug --jacoco $(pwd)/org.jacoco.agent-runtime.jar

# We don't want any coverage for IceGridGUI
find src/IceGridGUI -name '*.java' -exec rm {} \;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better if we don't need to remove files from the source tree. Specially if the script can be run locally as you can end up losing code changes.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we remove the class files like we do for the generated code?
They should all live in src/IceGridGUI/build/classes.

So maybe it'd be easier to just rm -rf src/IceGridGUI/build instead of using find ... -exec rm.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is a bug. I was attempting to remove the class files.

Comment on lines 10 to 11
# make -C ../cpp srcs
# make

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need these uncommented to actually run the build, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! Fixed.

python3 allTests.py --all --workers=4 --debug --jacoco $(pwd)/org.jacoco.agent-runtime.jar

# We don't want any coverage for IceGridGUI
find src/IceGridGUI -name '*.java' -exec rm {} \;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we remove the class files like we do for the generated code?
They should all live in src/IceGridGUI/build/classes.

So maybe it'd be easier to just rm -rf src/IceGridGUI/build instead of using find ... -exec rm.

# We don't want any coverage for generated code. We remove their class files and any inner classes.
jacocoArgs=()
for dir in src/*; do
[ -d "$dir" ] || continue

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I think the most correct solution is to just continue when dir == IceGridGui or whatever.
This means we don't need to find rm anything, which would be nice.

Also, the current approach feels a little weird. find src/IceGridGUI -name '*.java' -exec rm {} \; removes all the source files, but not the class files. So, we're still passing all the IceGridGUI classes to jacoco. But, I guess it doesn't display any output for them because it doesn't know about the source files?
Feels sketchy. It'd be better to just not pass the IceGridGui directory or anything at all IMO.

@externl externl merged commit 86d1ec6 into zeroc-ice:main Dec 11, 2024
19 checks passed
InsertCreativityHere pushed a commit to InsertCreativityHere/compiler-comparison that referenced this pull request Jan 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants