提交 54d568d2 编写于 作者: C Christoph Kutzinski

Prevent repeated array copy of DirectoryScanner's included files.

Previously, array was copied 3 times, now only once.
上级 578a2f5b
......@@ -137,10 +137,20 @@ public final class TestResult extends MetaTabulatedResult {
public void parse(long buildTime, DirectoryScanner results) throws IOException {
String[] includedFiles = results.getIncludedFiles();
File baseDir = results.getBasedir();
parse(buildTime,baseDir,includedFiles);
}
/**
* Collect reports from the given report files, while
* filtering out all files that were created before the given time.
*
* @since 1.426
*/
public void parse(long buildTime, File baseDir, String[] reportFiles) throws IOException {
boolean parsed=false;
for (String value : includedFiles) {
for (String value : reportFiles) {
File reportFile = new File(baseDir, value);
// only count files that were actually updated during this build
if ( (buildTime-3000/*error margin*/ <= reportFile.lastModified()) || !checkTimestamps) {
......@@ -165,7 +175,7 @@ public final class TestResult extends MetaTabulatedResult {
"I can't figure out what test results are new and what are old.\n" +
"Please keep the slave clock in sync with the master.");
File f = new File(baseDir,includedFiles[0]);
File f = new File(baseDir,reportFiles[0]);
throw new AbortException(
String.format(
"Test reports were found but none of them are new. Did tests run? %n"+
......
......@@ -134,14 +134,15 @@ public class SurefireArchiver extends MavenReporter {
FileSet fileSet = getFileSet(reportsDir);
DirectoryScanner ds = fileSet.getDirectoryScanner();
if(ds.getIncludedFiles().length==0)
if(ds.getIncludedFilesCount()==0)
// no test in this module
return true;
rememberCheckedFiles(reportsDir, ds);
String[] reportFiles = ds.getIncludedFiles();
rememberCheckedFiles(reportsDir, reportFiles);
if(result==null) result = new TestResult();
result.parse(System.currentTimeMillis() - build.getMilliSecsSinceBuildStart(), ds);
result.parse(System.currentTimeMillis() - build.getMilliSecsSinceBuildStart(), reportsDir, reportFiles);
int failCount = build.execute(new BuildCallable<Integer, IOException>() {
public Integer call(MavenBuild build) throws IOException, InterruptedException {
......@@ -209,10 +210,10 @@ public class SurefireArchiver extends MavenReporter {
/**
* Add checked files to the exclude list of the fileSet
*/
private void rememberCheckedFiles(File baseDir, DirectoryScanner ds) {
private void rememberCheckedFiles(File baseDir, String[] reportFiles) {
FileSet fileSet = getFileSet(baseDir);
for (String file : ds.getIncludedFiles()) {
for (String file : reportFiles) {
fileSet.setExcludes(file);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册