Copilot commented on code in PR #3646:
URL: https://github.com/apache/maven-surefire/pull/3646#discussion_r4731152000
##########
maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java:
##########
@@ -623,16 +625,29 @@ public void setRunLastFailed(boolean runLastFailed) {
@SuppressWarnings("unchecked")
protected void handleSummary(RunResult summary, Exception
firstForkException)
throws MojoExecutionException, MojoFailureException {
+ File summaryFile = getSummaryFile();
try {
+ // Executions sharing a summary file add up their results in it.
The flag is kept per file: the first
+ // write to a file in this build replaces what the previous build
left there.
+ String inProgressKey = FAILSAFE_IN_PROGRESS_CONTEXT_KEY + ":" +
toAbsoluteCanonical(summaryFile);
+ boolean inProgress = getPluginContext().containsKey(inProgressKey);
if (!summary.isNoTestsRun()) {
- Object token =
getPluginContext().get(FAILSAFE_IN_PROGRESS_CONTEXT_KEY);
- writeSummary(summary, getSummaryFile(), token != null);
+ writeSummary(summary, summaryFile, inProgress);
+ } else if (!inProgress && isFromAnEarlierBuild(summaryFile)) {
+ // nothing ran: drop the previous build's summary, but don't
create an empty one (SUREFIRE-2124)
+ Files.deleteIfExists(summaryFile.toPath());
Review Comment:
When parallel reactor modules share a summary file, an empty execution can
check its old timestamp, then another module can write this build's failing
result before `deleteIfExists` runs. The empty execution will delete that new
result, and `verify` tolerates the missing summary by default, potentially
allowing a failing build to pass. The per-module plugin-context flag cannot
prevent this interleaving. Coordinate the timestamp check and deletion with
summary writes using a lock shared across modules and keyed by the canonical
summary path.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]