Skip to content

Commit

Permalink
Fix JENKINS-9655 patch by Attila-Mihaly
Browse files Browse the repository at this point in the history
  • Loading branch information
Manolo Carrasco committed May 13, 2011
1 parent dd215a3 commit 9688ede
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 26 deletions.
Expand Up @@ -34,10 +34,10 @@ public PerformanceBuildAction(AbstractBuild<?, ?> pBuild, PrintStream logger,
this.parsers = parsers;
}

public PerformanceReportParser getParserById(String id) {
public PerformanceReportParser getParserByDisplayName(String displayName) {
if (parsers != null)
for (PerformanceReportParser parser : parsers)
if (parser.getDescriptor().getId().equals(id))
if (parser.getDescriptor().getDisplayName().equals(displayName))
return parser;
return null;
}
Expand Down
Expand Up @@ -336,20 +336,22 @@ private List<Integer> getFirstAndLastBuild(StaplerRequest request,

public List<String> getPerformanceReportList() {
this.performanceReportList = new ArrayList<String>(0);
if (this.project != null
&& this.project.getSomeBuildWithWorkspace() != null) {
File file = new File(
this.project.getSomeBuildWithWorkspace().getRootDir(),
PerformanceReportMap.getPerformanceReportDirRelativePath());
if (file.exists()) {
for (File performanceReportFile : file.listFiles()) {
this.performanceReportList.add(performanceReportFile.getName());
}
if (null == this.project) { return performanceReportList; }
if (null == this.project.getSomeBuildWithWorkspace()) { return performanceReportList; }
File file = new File(
this.project.getSomeBuildWithWorkspace().getRootDir(),
PerformanceReportMap.getPerformanceReportDirRelativePath());
if (!file.isDirectory()) { return performanceReportList; }

for (File entry : file.listFiles()) {
if (entry.isDirectory()) {
for (File e : entry.listFiles()) { this.performanceReportList.add(e.getName()); }
} else {
this.performanceReportList.add(entry.getName());
}
}
if (this.performanceReportList != null) {
Collections.sort(performanceReportList);
}

Collections.sort(performanceReportList);
return this.performanceReportList;
}

Expand Down
Expand Up @@ -74,10 +74,10 @@ public PerformancePublisher(int errorFailedThreshold,
}

public static File getPerformanceReport(AbstractBuild<?, ?> build,
String performanceReportName) {
String parserDisplayName, String performanceReportName) {
return new File(
build.getRootDir(),
PerformanceReportMap.getPerformanceReportFileRelativePath(getPerformanceReportBuildFileName(performanceReportName)));
PerformanceReportMap.getPerformanceReportFileRelativePath(parserDisplayName, getPerformanceReportBuildFileName(performanceReportName)));
}

@Override
Expand Down Expand Up @@ -195,7 +195,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
return true;
}

List<File> localReports = copyReportsToMaster(build, logger, files);
List<File> localReports = copyReportsToMaster(build, logger, files, parser.getDescriptor().getDisplayName());
Collection<PerformanceReport> parsedReports = parser.parse(build,
localReports, listener);

Expand All @@ -220,11 +220,11 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
}

private List<File> copyReportsToMaster(AbstractBuild<?, ?> build,
PrintStream logger, List<FilePath> files) throws IOException,
PrintStream logger, List<FilePath> files, String parserDisplayName) throws IOException,
InterruptedException {
List<File> localReports = new ArrayList<File>();
for (FilePath src : files) {
final File localReport = getPerformanceReport(build, src.getName());
final File localReport = getPerformanceReport(build, parserDisplayName, src.getName());
if (src.isDirectory()) {
logger.println("Performance: File '" + src.getName()
+ "' is a directory, not a Performance Report");
Expand Down
Expand Up @@ -72,7 +72,7 @@ public boolean accept(File f) {
// this may fail, if the build itself failed, we need to recover gracefully
if (dirs != null) {
for (File dir : dirs) {
PerformanceReportParser p = buildAction.getParserById(dir.getName());
PerformanceReportParser p = buildAction.getParserByDisplayName(dir.getName());
if (p != null) {
addAll(p.parse(getBuild(), Arrays.asList(dir.listFiles()), listener));
}
Expand Down Expand Up @@ -162,19 +162,19 @@ public void setPerformanceReportMap(
}

public static String getPerformanceReportFileRelativePath(
String reportFileName) {
return getRelativePath(reportFileName);
String parserDisplayName, String reportFileName) {
return getRelativePath(parserDisplayName, reportFileName);
}

public static String getPerformanceReportDirRelativePath() {
return getRelativePath(null);
return getRelativePath();
}

private static String getRelativePath(String reportFileName) {
private static String getRelativePath(String... suffixes) {
StringBuilder sb = new StringBuilder(100);
sb.append(PERFORMANCE_REPORTS_DIRECTORY);
if (reportFileName != null) {
sb.append("/").append(reportFileName);
for (String suffix : suffixes) {
sb.append(File.separator).append(suffix);
}
return sb.toString();
}
Expand Down

0 comments on commit 9688ede

Please sign in to comment.