Skip to content
Permalink
Browse files
[FIXED JENKINS-18410] AbstractTestResultAction should be a RunAction2…
… so it need not persist its owning build.

(cherry picked from commit fcdf749)

Conflicts:
	changelog.html
  • Loading branch information
jglick authored and olivergondza committed Jan 5, 2014
1 parent 0b20686 commit b53770c70f53084bb98e61985a6a9ba0bebdeb75
@@ -133,6 +133,7 @@ public boolean perform(AbstractBuild build, Launcher launcher,
TestResult result = parse(testResults, build, launcher, listener);

try {
// TODO can the build argument be omitted now, or is it used prior to the call to addAction?
action = new TestResultAction(build, result, listener);
} catch (NullPointerException npe) {
throw new AbortException(Messages.JUnitResultArchiver_BadXML(testResults));
@@ -173,7 +174,7 @@ public boolean perform(AbstractBuild build, Launcher launcher,
return true;
}

build.getActions().add(action);
build.addAction(action);
CHECKPOINT.report();

if (action.getResult().getFailCount() > 0)
@@ -62,11 +62,17 @@ public class TestResultAction extends AbstractTestResultAction<TestResultAction>
private Integer totalCount;
private List<Data> testData = new ArrayList<Data>();

@Deprecated
public TestResultAction(AbstractBuild owner, TestResult result, BuildListener listener) {
super(owner);
setResult(result, listener);
}

/** @since 1.544 */
public TestResultAction(TestResult result, BuildListener listener) {
this(null, result, listener);
}

/**
* Overwrites the {@link TestResult} by a new data set.
*/
@@ -28,6 +28,14 @@
import hudson.tasks.junit.CaseResult;
import hudson.util.*;
import hudson.util.ChartUtil.NumberOnlyBuildLabel;

import java.awt.*;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import jenkins.model.RunAction2;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
@@ -44,13 +52,6 @@
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;

import java.awt.*;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
* Common base class for recording test result.
*
@@ -61,15 +62,28 @@
* @author Kohsuke Kawaguchi
*/
@ExportedBean
public abstract class AbstractTestResultAction<T extends AbstractTestResultAction> implements HealthReportingAction {
public final AbstractBuild<?,?> owner;
public abstract class AbstractTestResultAction<T extends AbstractTestResultAction> implements HealthReportingAction, RunAction2 {
public transient AbstractBuild<?,?> owner;

private Map<String,String> descriptions = new ConcurrentHashMap<String, String>();

/** @since 1.544 */
protected AbstractTestResultAction() {}

/** @deprecated Use the default constructor and just call {@link Run#addAction} to associate the build with the action. */
@Deprecated
protected AbstractTestResultAction(AbstractBuild owner) {
this.owner = owner;
}

@Override public void onAttached(Run<?, ?> r) {
this.owner = (AbstractBuild<?,?>) r;
}

@Override public void onLoad(Run<?, ?> r) {
this.owner = (AbstractBuild<?,?>) r;
}

/**
* Gets the number of failed tests.
*/
@@ -67,10 +67,14 @@ public Child(String name, int build) {
*/
public final List<Child> children = new ArrayList<Child>();

@Deprecated
public AggregatedTestResultAction(AbstractBuild owner) {
super(owner);
}

/** @since 1.544 */
public AggregatedTestResultAction() {}

protected void update(List<? extends AbstractTestResultAction> children) {
failCount = skipCount = totalCount = 0;
this.children.clear();
@@ -87,7 +87,7 @@ public AggregatedTestResultPublisher(String jobs, boolean includeFailedBuilds) {

public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
// add a TestResult just so that it can show up later.
build.addAction(new TestResultAction(jobs,includeFailedBuilds,build));
build.addAction(new TestResultAction(jobs, includeFailedBuilds));
return true;
}

@@ -131,6 +131,11 @@ public static final class TestResultAction extends AbstractTestResultAction {
private transient List<AbstractProject> didntRun;
private transient List<AbstractProject> noFingerprints;

public TestResultAction(String jobs, boolean includeFailedBuilds) {
this(jobs, includeFailedBuilds, null);
}

@Deprecated
public TestResultAction(String jobs, boolean includeFailedBuilds, AbstractBuild<?,?> owner) {
super(owner);
this.includeFailedBuilds = includeFailedBuilds;
@@ -38,10 +38,15 @@
* @author Kohsuke Kawaguchi
*/
public class MatrixTestResult extends AggregatedTestResultAction {

@Deprecated
public MatrixTestResult(MatrixBuild owner) {
super(owner);
}

/** @since 1.544 */
public MatrixTestResult() {}

/**
* Use the configuration name.
*/
@@ -46,7 +46,7 @@ public TestResultAggregator(MatrixBuild build, Launcher launcher, BuildListener

@Override
public boolean startBuild() throws InterruptedException, IOException {
result = new MatrixTestResult(build);
result = new MatrixTestResult();
build.addAction(result);
return true;
}
@@ -32,12 +32,19 @@
public class TrivialTestResultAction extends AbstractTestResultAction<TrivialTestResultAction> implements StaplerProxy {

protected TrivialTestResult result;

@Deprecated
protected TrivialTestResultAction(AbstractBuild owner, TrivialTestResult result) {
super(owner);
this.result = result;
this.result.setParentAction(this);
}

/** @since 1.544 */
protected TrivialTestResultAction(TrivialTestResult result) {
this(null, result);
}

/**
* Gets the number of failed tests.
*/
@@ -48,9 +48,9 @@ public boolean perform(AbstractBuild<?, ?> build,
System.out.println("performing TrviialTestResultRecorder");
listener.getLogger().println("perfoming TrivialTestResultRecorder");
TrivialTestResult r = new TrivialTestResult("gubernatorial");
TrivialTestResultAction action = new TrivialTestResultAction(build, r);
TrivialTestResultAction action = new TrivialTestResultAction(r);
r.setParentAction(action);
build.getActions().add(action);
build.addAction(action);
listener.getLogger().println("done with TrivialTestResultRecorder");
System.out.println("done with TrivialTestResultRecorder");
return true;

0 comments on commit b53770c

Please sign in to comment.