Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
Merge pull request #325 from jglick/delete-workaround-JENKINS-30395
Browse files Browse the repository at this point in the history
[JENKINS-30395] Deleting workaround
  • Loading branch information
jglick committed Jan 25, 2016
2 parents 219921b + 109b8f8 commit 383ab81
Show file tree
Hide file tree
Showing 44 changed files with 44 additions and 154 deletions.
Expand Up @@ -52,7 +52,7 @@

public class BuildQueueTasksTest {

@Rule public RestartableJenkinsRule story = JenkinsRuleExt.workAroundJenkins30395Restartable();
@Rule public RestartableJenkinsRule story = new RestartableJenkinsRule();

@Issue("JENKINS-28649")
@Test public void queueAPI() throws Exception {
Expand Down
Expand Up @@ -50,7 +50,7 @@

public class CpsFlowExecutionTest {

@Rule public RestartableJenkinsRule story = JenkinsRuleExt.workAroundJenkins30395Restartable();
@Rule public RestartableJenkinsRule story = new RestartableJenkinsRule();

private static WeakReference<ClassLoader> LOADER;
public static void register(Object o) {
Expand Down
Expand Up @@ -60,7 +60,7 @@

public class CpsScmFlowDefinitionTest {

@Rule public JenkinsRule r = JenkinsRuleExt.workAroundJenkins30395();
@Rule public JenkinsRule r = new JenkinsRule();
@Rule public GitSampleRepoRule sampleRepo = new GitSampleRepoRule();

@Test public void basics() throws Exception {
Expand Down
Expand Up @@ -37,7 +37,7 @@
*/
public class DSLTest {

@Rule public JenkinsRule r = JenkinsRuleExt.workAroundJenkins30395();
@Rule public JenkinsRule r = new JenkinsRule();

@Test public void overrideFunction() throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
Expand Down
Expand Up @@ -49,7 +49,7 @@
public class DynamicEnvironmentExpanderTest {

@ClassRule public static BuildWatcher buildWatcher = new BuildWatcher();
@Rule public RestartableJenkinsRule story = JenkinsRuleExt.workAroundJenkins30395Restartable();
@Rule public RestartableJenkinsRule story = new RestartableJenkinsRule();

@Issue("JENKINS-26163")
@Test public void dynamics() {
Expand Down
Expand Up @@ -36,7 +36,7 @@
*/
public class EnvWorkflowTest {

@Rule public JenkinsRule r = JenkinsRuleExt.workAroundJenkins30395();
@Rule public JenkinsRule r = new JenkinsRule();

/**
* Verifies if NODE_NAME environment variable is available on a slave node and on master.
Expand Down
Expand Up @@ -34,22 +34,14 @@
import hudson.slaves.SlaveComputer;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.Description;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.Statement;
import org.jvnet.hudson.test.HudsonHomeLoader;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.RestartableJenkinsRule;

/**
* Utilities that could be added to {@link JenkinsRule} in the future but are not yet available in our baseline version.
* Utilities that could be added to {@link JenkinsRule} in the future but are not yet available in the selected {@code jenkins-test-harness}.
*/
public class JenkinsRuleExt {

Expand Down Expand Up @@ -88,61 +80,6 @@ private static class SpecialEnvComputer extends SlaveComputer {
}
}

public static JenkinsRule workAroundJenkins30395() {
return new JenkinsRule() {
@Override public void before() throws Throwable {
if (Thread.interrupted()) {
System.err.println("was interrupted before start");
}
super.before();
}
};
}
public static RestartableJenkinsRule workAroundJenkins30395Restartable() {
return new RestartableJenkinsRule() {
private Description description;
private final List<Statement> steps = new ArrayList<Statement>();
private TemporaryFolder tmp = new TemporaryFolder();
private Object target;
@Override
public Statement apply(final Statement base, FrameworkMethod method, Object target) {
this.description = Description.createTestDescription(
method.getMethod().getDeclaringClass(), method.getName(), method.getAnnotations());
this.target = target;
return tmp.apply(new Statement() {
@Override
public void evaluate() throws Throwable {
home = tmp.newFolder();
base.evaluate();
run();
}
}, description);
}
public void addStep(final Statement step) {
steps.add(new Statement() {
@Override
public void evaluate() throws Throwable {
j.jenkins.getInjector().injectMembers(step);
j.jenkins.getInjector().injectMembers(target);
step.evaluate();
}
});
}
private void run() throws Throwable {
HudsonHomeLoader loader = new HudsonHomeLoader() {
@Override
public File allocate() throws Exception {
return home;
}
};
for (Statement step : steps) {
j = workAroundJenkins30395().with(loader);
j.apply(step,description).evaluate();
}
}
};
}

private JenkinsRuleExt() {}

}
Expand Up @@ -39,7 +39,7 @@

public class ScalabilityTest {

@Rule public RestartableJenkinsRule story = JenkinsRuleExt.workAroundJenkins30395Restartable();
@Rule public RestartableJenkinsRule story = new RestartableJenkinsRule();

@Issue("JENKINS-30055")
@Test public void manySteps() {
Expand Down
Expand Up @@ -46,7 +46,7 @@
public abstract class SingleJobTestBase extends Assert {

@ClassRule public static BuildWatcher buildWatcher = new BuildWatcher();
@Rule public RestartableJenkinsRule story = JenkinsRuleExt.workAroundJenkins30395Restartable();
@Rule public RestartableJenkinsRule story = new RestartableJenkinsRule();

// currently executing workflow and its build
public WorkflowJob p;
Expand Down
Expand Up @@ -50,7 +50,7 @@
public class WorkflowRunRestartTest {

@ClassRule public static BuildWatcher buildWatcher = new BuildWatcher();
@Rule public RestartableJenkinsRule story = JenkinsRuleExt.workAroundJenkins30395Restartable();
@Rule public RestartableJenkinsRule story = new RestartableJenkinsRule();

@Issue("JENKINS-25550")
@Test public void hardKill() throws Exception {
Expand Down
Expand Up @@ -66,7 +66,7 @@
public class WorkflowRunTest {

@ClassRule public static BuildWatcher buildWatcher = new BuildWatcher();
@Rule public JenkinsRule r = JenkinsRuleExt.workAroundJenkins30395();
@Rule public JenkinsRule r = new JenkinsRule();

@Test public void basics() throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
Expand Down
Expand Up @@ -4,7 +4,6 @@
import static java.util.Arrays.asList;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.jenkinsci.plugins.workflow.JenkinsRuleExt;
import org.jenkinsci.plugins.workflow.cps.CpsThreadDump.ThreadInfo;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
Expand All @@ -20,7 +19,7 @@
public class CpsThreadDumpTest {

@ClassRule public static BuildWatcher buildWatcher = new BuildWatcher();
@Rule public JenkinsRule j = JenkinsRuleExt.workAroundJenkins30395();
@Rule public JenkinsRule j = new JenkinsRule();
private WorkflowJob p;

@Before
Expand Down
Expand Up @@ -15,7 +15,6 @@
import org.jvnet.hudson.test.RestartableJenkinsRule;
import javax.inject.Inject;
import org.apache.commons.io.FileUtils;
import org.jenkinsci.plugins.workflow.JenkinsRuleExt;
import org.jenkinsci.plugins.workflow.test.steps.SemaphoreStep;
import org.junit.runners.model.Statement;
import org.jvnet.hudson.test.JenkinsRule;
Expand All @@ -27,7 +26,7 @@
*/
public class WorkflowLibRepositoryTest {

@Rule public RestartableJenkinsRule story = JenkinsRuleExt.workAroundJenkins30395Restartable();
@Rule public RestartableJenkinsRule story = new RestartableJenkinsRule();

@Inject
Jenkins jenkins;
Expand Down
@@ -1,6 +1,5 @@
package org.jenkinsci.plugins.workflow.cps.steps;

import org.jenkinsci.plugins.workflow.JenkinsRuleExt;
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
Expand All @@ -18,7 +17,7 @@
public class LoadStepTest {

@ClassRule public static BuildWatcher buildWatcher = new BuildWatcher();
@Rule public JenkinsRule r = JenkinsRuleExt.workAroundJenkins30395();
@Rule public JenkinsRule r = new JenkinsRule();

@Test
public void basics() throws Exception {
Expand Down
Expand Up @@ -2,7 +2,6 @@

import javax.inject.Inject;
import jenkins.model.Jenkins;
import org.jenkinsci.plugins.workflow.JenkinsRuleExt;
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
Expand All @@ -20,7 +19,7 @@
* @author Kohsuke Kawaguchi
*/
public class RestartingLoadStepTest {
@Rule public RestartableJenkinsRule story = JenkinsRuleExt.workAroundJenkins30395Restartable();
@Rule public RestartableJenkinsRule story = new RestartableJenkinsRule();

@Inject
Jenkins jenkins;
Expand Down
Expand Up @@ -12,13 +12,12 @@
import org.jvnet.hudson.test.JenkinsRule;

import java.util.Arrays;
import org.jenkinsci.plugins.workflow.JenkinsRuleExt;

/**
* @author Kohsuke Kawaguchi
*/
public class ArtifactArchiverStepTest extends Assert {
@Rule public JenkinsRule j = JenkinsRuleExt.workAroundJenkins30395();
@Rule public JenkinsRule j = new JenkinsRule();

/**
* Archive and unarchive file
Expand Down
Expand Up @@ -26,7 +26,6 @@

import hudson.model.Result;
import jenkins.model.CauseOfInterruption;
import org.jenkinsci.plugins.workflow.JenkinsRuleExt;
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
Expand All @@ -37,7 +36,7 @@

public class CatchErrorStepTest {

@Rule public JenkinsRule r = JenkinsRuleExt.workAroundJenkins30395();
@Rule public JenkinsRule r = new JenkinsRule();

@Test public void specialStatus() throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
Expand Down
Expand Up @@ -30,7 +30,6 @@
import hudson.tasks.junit.TestResultAction;
import java.util.List;
import javax.mail.internet.InternetAddress;
import org.jenkinsci.plugins.workflow.JenkinsRuleExt;
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
Expand All @@ -45,7 +44,7 @@
public class CoreStepTest {

@ClassRule public static BuildWatcher buildWatcher = new BuildWatcher();
@Rule public JenkinsRule r = JenkinsRuleExt.workAroundJenkins30395();
@Rule public JenkinsRule r = new JenkinsRule();

@Test public void artifactArchiver() throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
Expand Down
Expand Up @@ -62,7 +62,7 @@
public class CoreWrapperStepTest {

@ClassRule public static BuildWatcher buildWatcher = new BuildWatcher();
@Rule public RestartableJenkinsRule story = JenkinsRuleExt.workAroundJenkins30395Restartable();
@Rule public RestartableJenkinsRule story = new RestartableJenkinsRule();

@Test public void useWrapper() throws Exception {
story.addStep(new Statement() {
Expand Down
Expand Up @@ -25,25 +25,19 @@
package org.jenkinsci.plugins.workflow.steps;

import java.io.File;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;

import hudson.FilePath;
import hudson.model.queue.QueueTaskFuture;
import org.jenkinsci.plugins.workflow.JenkinsRuleExt;

public class DeleteDirStepTest {

@Rule public JenkinsRule r = JenkinsRuleExt.workAroundJenkins30395();
@Rule public JenkinsRule r = new JenkinsRule();

@Test
public void testDeleteEmptyWorkspace() throws Exception {
Expand Down
Expand Up @@ -29,7 +29,6 @@
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jenkinsci.plugins.workflow.JenkinsRuleExt;
import org.jenkinsci.plugins.workflow.actions.LogAction;
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.graph.FlowGraphWalker;
Expand All @@ -46,7 +45,7 @@
public class EchoStepTest {

@ClassRule public static BuildWatcher buildWatcher = new BuildWatcher();
@Rule public JenkinsRule r = JenkinsRuleExt.workAroundJenkins30395();
@Rule public JenkinsRule r = new JenkinsRule();

@Test public void smokes() throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
Expand Down
Expand Up @@ -24,7 +24,6 @@

package org.jenkinsci.plugins.workflow.steps;

import org.jenkinsci.plugins.workflow.JenkinsRuleExt;
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
Expand All @@ -39,7 +38,7 @@
public class EnvStepTest {

@ClassRule public static BuildWatcher buildWatcher = new BuildWatcher();
@Rule public RestartableJenkinsRule story = JenkinsRuleExt.workAroundJenkins30395Restartable();
@Rule public RestartableJenkinsRule story = new RestartableJenkinsRule();

@Test public void overriding() {
story.addStep(new Statement() {
Expand Down
Expand Up @@ -24,7 +24,6 @@

package org.jenkinsci.plugins.workflow.steps;

import org.jenkinsci.plugins.workflow.JenkinsRuleExt;
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.junit.Test;
Expand All @@ -33,7 +32,7 @@

public class IsUnixStepTest {

@Rule public JenkinsRule r = JenkinsRuleExt.workAroundJenkins30395();
@Rule public JenkinsRule r = new JenkinsRule();

@Test public void basics() throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
Expand Down

0 comments on commit 383ab81

Please sign in to comment.