Skip to content

Commit

Permalink
[FIXED JENKINS-31524]
Browse files Browse the repository at this point in the history
- Handle the case where existing test results have been updated by a subsequent test MOJO execution within the same build.
  • Loading branch information
demonfiddler committed Nov 13, 2015
1 parent bb25b85 commit 5945f85
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/java/hudson/maven/reporters/SurefireArchiver.java
Expand Up @@ -74,10 +74,10 @@ public class SurefireArchiver extends TestFailureDetector {
private final AtomicBoolean hasTestFailures = new AtomicBoolean();

/**
* Store result files already parsed, so we don't parse them again,
* if a later running mojo specifies the same reports directory.
* Store result files and modification timestamps already parsed, so we don't parse them again
* if a later running MOJO specifies the same reports directory.
*/
private transient ConcurrentMap<File, File> parsedFiles = new ConcurrentHashMap<File,File>();
private transient ConcurrentMap<File, Long> parsedFiles = new ConcurrentHashMap<File, Long>();

@Override
public boolean hasTestFailures() {
Expand Down Expand Up @@ -138,7 +138,7 @@ public boolean postExecute(MavenBuildProxy build, MavenProject pom, MojoInfo moj
fileSet = Iterables.filter(fileSet, new Predicate<File>() {
@Override
public boolean apply(File input) {
return !parsedFiles.containsKey(input);
return !parsedFiles.containsKey(input) || parsedFiles.get(input) < input.lastModified();
}
});

Expand Down Expand Up @@ -213,7 +213,7 @@ private void markBuildAsSuccess(Throwable mojoError, MavenBuildInformation build
*/
private void rememberCheckedFiles(Iterable<File> fileSet) {
for (File f : fileSet) {
this.parsedFiles.put(f, f);
this.parsedFiles.put(f, f.lastModified());
}
}

Expand Down Expand Up @@ -330,7 +330,7 @@ private TestMojo getTestMojo(MojoInfo mojo) {
// I'm not sure if SurefireArchiver is actually ever (de-)serialized,
// but just to be sure, set fileSets here
protected Object readResolve() {
parsedFiles = new ConcurrentHashMap<File,File>();
parsedFiles = new ConcurrentHashMap<File, Long>();
return this;
}

Expand Down

0 comments on commit 5945f85

Please sign in to comment.