Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

New flag to enable/disable display of source files with line coverage highlights #81

Merged
merged 4 commits into from
Feb 24, 2017

Conversation

aditi-rajawat
Copy link
Contributor

Added a new flag named "Disable display of source files for coverage" to allow the end-user to choose whether to copy source files or not. This is a required use-case as some applications have thousands of source files and Jacoco plugin consumes lot of time to copy the files to the master node. Users are not always interested in viewing the line coverage highlights in source files specially when the application have thousands or more files. Providing an option will serve the purpose.
skipcopyofsrcfiles

Copy link
Member

@centic9 centic9 left a comment

Choose a reason for hiding this comment

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

Thanks for the suggestion, it looks ok overall, only the removal of the log-statements looks odd, please comment or revert those changes.

Additionally a unit-test verifying the feature would be good to have the new feature covered.

@@ -451,13 +461,18 @@ public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath filePath, @Nonnull
logger.print("\n[JaCoCo plugin] Saving matched class directories for class-pattern: " + classPattern + ": ");
for (FilePath file : matchedClassDirs) {
dir.saveClassesFrom(file);
logger.print(" " + file);
Copy link
Member

Choose a reason for hiding this comment

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

These log-outputs were done on purpose to help with investigation of problems, any reason why you removed them as part of this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have integrated jacoco plugin with a CI build job of a application having thousands of classes. The log statement prints numerous file paths on CI log which seemed unnecessary. For investigation can we add a summary message instead? Please suggest. Thanks.

Copy link
Member

Choose a reason for hiding this comment

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

these should only be the top-level class dirs, e.g. build/classes, not each separate directory underneath. This sounds like you configured it in a way so that it selected all those separately one-by-one instead of only the top-level dir. Can you try to configure it differently and see if the printout looks sane then while still collecting coverage?

Copy link
Member

Choose a reason for hiding this comment

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

E.g. you can take a look at the build at https://builds.apache.org/view/POI/job/POI-DSL-1.6/, it has thousands of class-files as well, but we only configure the class-directories "build/classes,build/excelant-classes,build/ooxml-classes,build/scratchpad-classes,build/*/build/classes", this results in the following nice and helpful log-output:

[JaCoCo plugin] Collecting JaCoCo coverage data...
[JaCoCo plugin] build/*.exec,build/*/build/jacoco/*.exec;build/classes,build/excelant-classes,build/ooxml-classes,build/scratchpad-classes,build/*/build/classes;src/java,src/excelant/java,src/ooxml/java,src/scratchpad/src; locations are configured

Configuring it differently so that it needs to iterate over all classes separately might even cause quite an overhead when executing the plugin...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@centic9 I am in process of verifying your suggestion in my CI job.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@centic9 Turns out the log message problem was due to a '/' after my class directory name which caused it to iterate over every sub-directory as you mentioned. Proper class directory has reduced the total execution time as well. This was a great help and I appreciate your suggestions. I have added the log messages back as part of this PR.

logger.print("\n[JaCoCo plugin] Saving matched source directories for source-pattern: " + sourcePattern + ": ");
for (FilePath file : matchedSrcDirs) {
dir.saveSourcesFrom(file);
logger.print(" " + file);
Copy link
Member

Choose a reason for hiding this comment

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

dito

@TobiX
Copy link

TobiX commented Feb 22, 2017

Don't you get the same behaviour by unsetting sourcePattern?

@aditi-rajawat
Copy link
Contributor Author

@centic9 I have added the unit tests for verification.
@TobiX We get the same behavior but only on the UI. The plugin copies entire workspace on the master node which degrades the performance further than just specifying the source directory.

@centic9 centic9 merged commit c4f698f into jenkinsci:master Feb 24, 2017
@centic9
Copy link
Member

centic9 commented Feb 24, 2017

Thanks for the PR, this is merged now and will be included in the next release of the plugin.

@aditi-rajawat
Copy link
Contributor Author

Thank you @centic9 for accepting the PR.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants