Bug 455656 - Error in performance results analysis, if more recent build
exists in database.
diff --git a/bundles/org.eclipse.test.performance.ui/src/org/eclipse/test/internal/performance/results/db/PerformanceResults.java b/bundles/org.eclipse.test.performance.ui/src/org/eclipse/test/internal/performance/results/db/PerformanceResults.java
index 2da6cc6..281eb66 100644
--- a/bundles/org.eclipse.test.performance.ui/src/org/eclipse/test/internal/performance/results/db/PerformanceResults.java
+++ b/bundles/org.eclipse.test.performance.ui/src/org/eclipse/test/internal/performance/results/db/PerformanceResults.java
@@ -670,19 +670,36 @@
if (n < buildsSize) {
System.arraycopy(this.allBuildNames, 0, this.allBuildNames = new String[n], 0, n);
}
- int idx = n-1;
- String lastBuild = this.allBuildNames[idx--];
- while (idx > 0 && lastBuild.startsWith(DB_Results.getDbBaselinePrefix())) {
- lastBuild = this.allBuildNames[idx--];
- }
- this.needToUpdateLocalFile = this.name == null || Util.getBuildDate(lastBuild).compareTo(Util.getBuildDate(this.name)) > 0;
- this.name = lastBuild;
- if (this.baselineName != null) {
- String lastBuildDate = Util.getBuildDate(lastBuild);
- if (Util.getBuildDate(this.baselineName).compareTo(lastBuildDate) > 0) {
- this.baselineName = DB_Results.getLastBaselineBuild(lastBuildDate);
- }
- }
+ // there are times when the build we want to analyze is not the
+ // "last build",
+ // such as there may have be subsequent builds, already.
+ // so, we only compute this "default behavior" of finding last build,
+ // and equating it to "name", only if lastBuildName has not been set yet.
+ // For the case where "-current" is passed as an argument, in GenerateResults, we do
+ // "setLastBuildName" to "current". See bug 455656.
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=455656
+ String lastBuild = null;
+ // Note: we can not call "getLastBuildName()" because it has the side effects we are
+ // trying to avoid.
+ if (this.lastBuildName == null) {
+ int idx = n - 1;
+ lastBuild = this.allBuildNames[idx--];
+ while (idx > 0 && lastBuild.startsWith(DB_Results.getDbBaselinePrefix())) {
+ lastBuild = this.allBuildNames[idx--];
+ }
+ } else {
+ lastBuild = this.lastBuildName;
+ this.name = lastBuild;
+ }
+ this.needToUpdateLocalFile = this.name == null
+ || Util.getBuildDate(lastBuild).compareTo(Util.getBuildDate(this.name)) > 0;
+ this.name = lastBuild;
+ if (this.baselineName != null) {
+ String lastBuildDate = Util.getBuildDate(lastBuild);
+ if (Util.getBuildDate(this.baselineName).compareTo(lastBuildDate) > 0) {
+ this.baselineName = DB_Results.getLastBaselineBuild(lastBuildDate);
+ }
+ }
}
}
diff --git a/bundles/org.eclipse.test.performance.ui/src/org/eclipse/test/performance/ui/GenerateResults.java b/bundles/org.eclipse.test.performance.ui/src/org/eclipse/test/performance/ui/GenerateResults.java
index b658a94..dd1b12a 100644
--- a/bundles/org.eclipse.test.performance.ui/src/org/eclipse/test/performance/ui/GenerateResults.java
+++ b/bundles/org.eclipse.test.performance.ui/src/org/eclipse/test/performance/ui/GenerateResults.java
@@ -1000,11 +1000,17 @@
}
}
+ // must set our known "last build" (that we are interested in) before
+ // 'getAllBuildNames' is called, else it may set "name" to some later
+ // build we are not interested in analyzing yet.
+ this.performanceResults.setLastBuildName(buildName);
+
// Verify that build is known
String[] builds = this.performanceResults.getAllBuildNames();
if (builds == null || builds.length == 0) {
System.err.println("Cannot connect to database to generate results build '"+buildName+"'");
- System.exit(1);
+ // TODO: changed a system.exit to this exception ... but, there might be better choices?
+ throw new IllegalStateException("Cannot connect to database to generate results build '"+buildName+"'");
}
if (Arrays.binarySearch(builds, buildName, Util.BUILD_DATE_COMPARATOR) < 0) {
throw new RuntimeException("No results in database for build '"+buildName+"'");
@@ -1028,12 +1034,17 @@
// Init current build prefixes if not set
if (this.currentBuildPrefixes == null) {
this.currentBuildPrefixes = new ArrayList();
- if (buildName.charAt(0) == 'M') {
+ char buildType = buildName.charAt(0);
+ if (buildType == 'M') {
this.currentBuildPrefixes.add("M");
- } else {
+ } else if (buildType == 'N') {
this.currentBuildPrefixes.add("N");
- }
+ } else if (buildType == 'I') {
this.currentBuildPrefixes.add("I");
+ } else {
+ // TODO: may want to throw error here?
+ this.currentBuildPrefixes.add("?");
+ }
}
}