Skip to content
Permalink
Browse files

[FIXED JENKINS-31524]

- 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 12, 2015
1 parent bb25b85 commit 5945f85d9d12b430315cf2124dde0727197a395f
Showing with 6 additions and 6 deletions.
  1. +6 −6 src/main/java/hudson/maven/reporters/SurefireArchiver.java
@@ -74,10 +74,10 @@
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() {
@@ -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();
}
});

@@ -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());
}
}

@@ -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;
}

0 comments on commit 5945f85

Please sign in to comment.
You can’t perform that action at this time.