-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Stack trace printed when no test classes are run (Surefire 2.12.2+) #19
Comments
Probably a simple one-line warning would be the best, as proposed here: http://sourceforge.net/tracker/?func=detail&aid=3563431&group_id=177969&atid=883351 |
Thanks for the feedback and for providing the link to the existing issue. I like the general concept, though I wonder if logging a warning might be too alarming, given that valid configurations would trigger this behavior. Here's a possible alternative: instead of modifying the default behavior, introduce an "ignoreMissingDataFile" parameter that suppresses the stack trace and replaces it with an INFO message if the file is missing and the setting is set to "true." When set to "false" (the default), the current behavior remains unchanged (though I believe most plugins actually fail the build on error as opposed to just printing the stack trace). What do you think? I can submit a pull request for this if that'd be helpful. |
What if we simply log an INFO message if the file does not exist? (we should still dump an ERROR if the file exists but can not be read). |
That seems reasonable. Would you like me to submit a pull request? Or is someone already working on it? |
Of course feel free to submit pull request - this might speed-up resolution of this issue, however take a look on our conventions http://www.eclemma.org/jacoco/trunk/doc/conventions.html , what implies that patch must be well-formated and tested. |
…generation if execution data file is missing
BTW, I can imagine another way to fix this issue: AgentMojo can create an empty jacoco.exec file, thus it will exist even if surefire wasn't executed. Guys, WDYT? |
I prefer to separate concerns and go with the proposed fix. There might be scenarios where we want to use agent and reporting separately. |
Creating the empty file was actually the first approach I tried - it does work, but I think it's a bit questionable in that it creates additional pre-/post-conditions that aren't necessarily obvious at first glance. On the other hand, I can't really think of a use case in which the reporting goal would be used without executing the agent goal first. While I don't think the proposed fix is perfect, I think the separation of concerns argument is still fairly compelling. |
Here is my vision:
And now main question here - do we want to stop ReportMojo immediately if dump not exists or not? And I don't see how creation of file in AgentMojo breaks concept of separation, because this is exactly the job of AgentMojo - prepare for collection of coverage and this preparation may mean creation of a file. But maybe I miss something? |
No, that seems reasonable. I've just been a wary of relying too heavily on side effects, though it's clear that the situation requires them to some degree (though the question is "to what degree?"). I do agree that fail-fast execution is desired here - this is why I consider the proposed solution to be imperfect. I'm really fine with either approach. |
Ok, so @marchof we're waiting your decision ;) |
As a side note, the missing file doesn't actually trigger a build failure - it just prints a stack trace and exits normally. So to actually get that fail-fast behavior, that logic should be modified as well. |
@atomicknight good point! |
On the other side - no need to create dump file by AgentMojo, if current project even not designed to contain tests (e.g. just to create package with application). |
I didn't quite follow that last comment - could you elaborate? |
What is the exact situation we're targeting here? Is it
|
For me, the situation is:
|
From the discussion I don't see a final solution that covers all issues raised here. So my proposal is to go with a slightly modified version of atomicknight's patch as a first step as it improves the current situation a bit:
Can we agree on this and open new issues for the other aspects? |
LGTM, so I'll do this today. |
Sounds good. I've updated the pull request to trigger a build failure when the execution data file cannot be read. I wasn't sure if it made sense to log an error in addition to throwing the exception (since the latter prints the message already), but I left it in anyway. |
…s specified for the report Mojo
which is good. An optimization could be to suppress this message—and also suppress any activity from |
@jglick Feel free to create separate issue. |
Version 2.12.2 of the maven-surefire-plugin includes an optimization that avoids forking the JVM if a fork mode of "once" is specified and there are no tests to run. Consequently, there is no guarantee that the Jacoco data file will be generated, leading to the following stack trace when the above conditions are met:
I'm not sure how this should be addressed. The simplest solution is to just ignore the missing data file, but that might not be desirable in all situations.
The text was updated successfully, but these errors were encountered: