Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-23713] Compatibility with SimpleBuildStep.
  • Loading branch information
jglick committed Aug 11, 2014
1 parent 85b64ee commit 4ba5a49
Show file tree
Hide file tree
Showing 38 changed files with 348 additions and 177 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.575</version>
<version>1.577-SNAPSHOT</version>
</parent>
<artifactId>junit</artifactId>
<version>1.1-SNAPSHOT</version>
Expand Down
17 changes: 8 additions & 9 deletions src/main/java/hudson/tasks/junit/CaseResult.java
Expand Up @@ -27,7 +27,6 @@
import org.apache.commons.io.FileUtils;
import org.jvnet.localizer.Localizable;

import hudson.model.AbstractBuild;
import hudson.model.Run;
import hudson.tasks.test.TestResult;

Expand Down Expand Up @@ -374,8 +373,8 @@ public int getFailedSince() {
CaseResult prev = getPreviousResult();
if(prev!=null && !prev.isPassed())
this.failedSince = prev.getFailedSince();
else if (getOwner() != null) {
this.failedSince = getOwner().getNumber();
else if (getRun() != null) {
this.failedSince = getRun().getNumber();
} else {
LOGGER.warning("trouble calculating getFailedSince. We've got prev, but no owner.");
// failedSince will be 0, which isn't correct.
Expand All @@ -385,7 +384,7 @@ else if (getOwner() != null) {
}

public Run<?,?> getFailedSinceRun() {
return getOwner().getParent().getBuildByNumber(getFailedSince());
return getRun().getParent().getBuildByNumber(getFailedSince());
}

/**
Expand All @@ -396,8 +395,8 @@ public Run<?,?> getFailedSinceRun() {
public int getAge() {
if(isPassed())
return 0;
else if (getOwner() != null) {
return getOwner().getNumber()-getFailedSince()+1;
else if (getRun() != null) {
return getRun().getNumber()-getFailedSince()+1;
} else {
LOGGER.fine("Trying to get age of a CaseResult without an owner");
return 0;
Expand Down Expand Up @@ -553,14 +552,14 @@ public SuiteResult getSuiteResult() {
}

@Override
public AbstractBuild<?,?> getOwner() {
public Run<?,?> getRun() {
SuiteResult sr = getSuiteResult();
if (sr==null) {
LOGGER.warning("In getOwner(), getSuiteResult is null"); return null; }
hudson.tasks.junit.TestResult tr = sr.getParent();
if (tr==null) {
LOGGER.warning("In getOwner(), suiteResult.getParent() is null."); return null; }
return tr.getOwner();
return tr.getRun();
}

public void setParentSuiteResult(SuiteResult parent) {
Expand All @@ -575,7 +574,7 @@ public void freeze(SuiteResult parent) {
if(prev!=null && !prev.isPassed())
this.failedSince = prev.failedSince;
else
this.failedSince = getOwner().getNumber();
this.failedSince = getRun().getNumber();
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/hudson/tasks/junit/ClassResult.java
Expand Up @@ -23,7 +23,7 @@
*/
package hudson.tasks.junit;

import hudson.model.AbstractBuild;
import hudson.model.Run;
import hudson.tasks.test.TabulatedResult;
import hudson.tasks.test.TestResult;
import hudson.tasks.test.TestObject;
Expand Down Expand Up @@ -58,8 +58,8 @@ public final class ClassResult extends TabulatedResult implements Comparable<Cla
}

@Override
public AbstractBuild<?, ?> getOwner() {
return (parent==null ? null: parent.getOwner());
public Run<?, ?> getRun() {
return (parent==null ? null: parent.getRun());
}

public PackageResult getParent() {
Expand Down
22 changes: 12 additions & 10 deletions src/main/java/hudson/tasks/junit/History.java
Expand Up @@ -24,6 +24,7 @@
package hudson.tasks.junit;

import hudson.model.AbstractBuild;
import hudson.model.Run;
import jenkins.model.Jenkins;
import hudson.tasks.test.TestObject;
import hudson.tasks.test.TestResult;
Expand Down Expand Up @@ -68,18 +69,18 @@ public TestObject getTestObject() {
}

public boolean historyAvailable() {
if (testObject.getOwner().getParent().getBuilds().size() > 1)
if (testObject.getRun().getParent().getBuilds().size() > 1)
return true;
else
return false;
}

public List<TestResult> getList(int start, int end) {
List<TestResult> list = new ArrayList<TestResult>();
end = Math.min(end, testObject.getOwner().getParent().getBuilds().size());
for (AbstractBuild<?,?> b: testObject.getOwner().getParent().getBuilds().subList(start, end)) {
end = Math.min(end, testObject.getRun().getParent().getBuilds().size());
for (Run<?,?> b: testObject.getRun().getParent().getBuilds().subList(start, end)) {
if (b.isBuilding()) continue;
TestResult o = testObject.getResultInBuild(b);
TestResult o = testObject.getResultInRun(b);
if (o != null) {
list.add(o);
}
Expand All @@ -88,7 +89,7 @@ public List<TestResult> getList(int start, int end) {
}

public List<TestResult> getList() {
return getList(0, testObject.getOwner().getParent().getBuilds().size());
return getList(0, testObject.getRun().getParent().getBuilds().size());
}

/**
Expand Down Expand Up @@ -223,7 +224,7 @@ public String generateURL(CategoryDataset dataset, int row,
public String generateToolTip(CategoryDataset dataset, int row,
int column) {
ChartLabel label = (ChartLabel) dataset.getColumnKey(column);
return label.o.getOwner().getDisplayName() + " : "
return label.o.getRun().getDisplayName() + " : "
+ label.o.getDurationString();
}
};
Expand Down Expand Up @@ -253,14 +254,14 @@ public String getUrl() {
}

private void generateUrl() {
AbstractBuild<?,?> build = o.getOwner();
Run<?,?> build = o.getRun();
String buildLink = build.getUrl();
String actionUrl = o.getTestResultAction().getUrlName();
this.url = Jenkins.getInstance().getRootUrl() + buildLink + actionUrl + o.getUrl();
}

public int compareTo(ChartLabel that) {
return this.o.getOwner().number - that.o.getOwner().number;
return this.o.getRun().number - that.o.getRun().number;
}

@Override
Expand All @@ -283,8 +284,9 @@ public int hashCode() {

@Override
public String toString() {
String l = o.getOwner().getDisplayName();
String s = o.getOwner().getBuiltOnStr();
Run<?, ?> run = o.getRun();
String l = run.getDisplayName();
String s = run instanceof AbstractBuild ? ((AbstractBuild) run).getBuiltOnStr() : null;
if (s != null)
l += ' ' + s;
return l;
Expand Down
10 changes: 3 additions & 7 deletions src/main/java/hudson/tasks/junit/JUnitParser.java
Expand Up @@ -25,8 +25,8 @@

import hudson.model.TaskListener;
import hudson.tasks.test.TestResultParser;
import hudson.model.AbstractBuild;
import hudson.*;
import hudson.model.Run;
import hudson.remoting.VirtualChannel;

import java.io.IOException;
Expand Down Expand Up @@ -69,8 +69,8 @@ public String getTestResultLocationMessage() {
}

@Override
public TestResult parse(String testResultLocations,
AbstractBuild build, Launcher launcher,
public TestResult parseResult(String testResultLocations,

This comment has been minimized.

Copy link
@daniel-beck

daniel-beck Oct 30, 2014

Member

Backwards incompatible change as it appears to have caused JENKINS-25375.

Run<?,?> build, FilePath workspace, Launcher launcher,
TaskListener listener)
throws InterruptedException, IOException
{
Expand All @@ -80,10 +80,6 @@ public TestResult parse(String testResultLocations,
// [BUG 3123310] TODO - Test Result Refactor: review and fix TestDataPublisher/TestAction subsystem]
// also get code that deals with testDataPublishers from JUnitResultArchiver.perform

FilePath workspace = build.getWorkspace();
if (workspace == null) {
throw new AbortException(Messages.JUnitParser_no_workspace_found(build));
}
return workspace.act(new ParseResultCallable(testResultLocations, buildTime, timeOnMaster, keepLongStdio));
}

Expand Down

0 comments on commit 4ba5a49

Please sign in to comment.