-
Notifications
You must be signed in to change notification settings - Fork 6
Fix issue with submodules looking at other submodule class files #31
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @rrourke
Thank you for your contribution.
I leaved a few comments in your PR. Just trying to understand what issue(s) you want to fix
return reactorProjects.asSequence() | ||
.map { project -> File(project.build.outputDirectory) } | ||
.filter { outputDirectory -> outputDirectory.exists() } | ||
.filter { outputDirectory -> outputDirectory.exists() && outputDirectory.path.contains(rootProjectDir.path)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cannot understand why do we need this check. Could you explain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might not need this, was from before. I'll remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tested it, this is still needed. Without this the class files are not filtered and all classes for all modules are exposed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, still cannot get it. Could you provide a sample project or integration tests, so I can see a project setup?
Existing IT here: https://github.com/SurpSG/diff-coverage-maven-plugin/tree/master/src/it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is going to take me a while to make to make a project that hits this criteria but think of it like this.
project demo
Sub modules:
- A
- B
- C
Module build order is project demo -> a -> b ->c.
Code changes are made to sub module a, unit tests are added passes code coverage.
B now runs and it detects the classes from module a, its new classes from module b(self) and will pass jacoc but will fail code coverage because there are no tests for classes from a in its jacoco that only ran on b.
you will see:
Classes
[INFO] [/Users/.../demo/target/classes, /Users/.../demo/target/a/classes, /Users/.../demo/b/target/classes, /Users/.../demo/b/target/classes]
so when the code coverage runs it will look at the classes in a see that no tests were run in jacoco and then fail.
My change makes it so what is seen is this
Classes
[INFO] [/Users/.../demo/b/target/classes]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SurpSG https://github.com/rrourke/mvn-example/tree/quickTest here is an example repo. Checkout the quickTest repo and run mvn install clean
you will see it fail for the reasons i mentioned above. You can then use my code for diff-covrage-maven-plugin and you will see it pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I got it, thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Np, just let me know what else I need to do to get this merged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to add several integration tests
https://github.com/SurpSG/diff-coverage-maven-plugin/tree/master/src/it
} | ||
if (!found) { | ||
log.info("No exec files found skipping") | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain your motivation?
Exec files are always appear if tests are run. From my experience, missed exec files it's misconfiguration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not all modules might have unit tests, this might be redundant since I changed how it scans.
|
||
private val rootProjectDir: File | ||
get() = reactorProjects[0].basedir | ||
get() = project.basedir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When there are sub modules it scans for all class files or if using the -rf flag it will use the base dir of the first module ran. In either case the class files it scans for are either just from the first module or it looks at all modules. This causes problems as if you have sub module a, b, and c if you make changes to b than when c runs the code change was in b but the jacoco for c doesn't have the unit tests and thus fails. Making this change makes it so it only looks at the class files for the module that is running the tests.
@SurpSG I've made some changes let me know what you think |
@SurpSG saw the test failed added missing path files that were not added |
Hi @rrourke Thank you for this awesome work! Still investigating your PR. |
@SurpSG looks like it failed on itself, what do you want to do from here? |
The plugin is applied to itself. It reported that coverage is not enough. Suppose, we have a structure:
What I expect:
Currently, it has a different behavior. How it was implemented in jacoco maven plugin to receive the aggregated report? Recommendations from the jacoco team:
DiffCoverage maven plugin currently can work in the same way. See integration test: (multi-module-reports-generation-check)[https://github.com/SurpSG/diff-coverage-maven-plugin/tree/master/src/it/multi-module-reports-generation-check] What we can do:
|
This fixes a problem with submodules where if it was previously built even using mvn clean it will look in other sub modules for their class files. Class files should be isolated to the module that the diff is being performed on.
This will also skip running if a jacoco file is not found.