Skip to content

Commit

Permalink
[JENKINS-42971] Simplifyied test
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinKosicky committed Aug 5, 2022
1 parent 779f53c commit 5e5aea3
Showing 1 changed file with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -204,29 +205,23 @@ public class CpsScmFlowDefinitionTest {
@Issue("JENKINS-42971")
@Test
public void lightweight_brach_parametrised() throws Exception {
LoggerRule lr = new LoggerRule();
lr.record(GitSCMFileSystem.class.getName(), Level.ALL).capture(4024);

sampleRepo.init();
sampleRepo.git("checkout","-b","master2");
sampleRepo.write("flow.groovy", "echo 'version one'");
sampleRepo.git("add", "flow.groovy");
sampleRepo.git("commit", "--message=init");
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
p.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("BRANCH","","")));
GitStep step = new GitStep(sampleRepo.toString());
step.setBranch("${BRANCH}");
GitSCM scm = new GitSCM(GitSCM.createRepoList(sampleRepo.toString(), null),
new ArrayList<BranchSpec>() {{
add(new BranchSpec("${BRANCH}"));
}}, null, null, Collections.emptyList());

CpsScmFlowDefinition def = new CpsScmFlowDefinition(step.createSCM(), "flow.groovy");
CpsScmFlowDefinition def = new CpsScmFlowDefinition(scm, "flow.groovy");
def.setLightweight(true);
TestDurabilityHintProvider provider = Jenkins.get().getExtensionList(TestDurabilityHintProvider.class).get(0);
provider.registerHint("p", FlowDurabilityHint.PERFORMANCE_OPTIMIZED);
p.setDefinition(def);

WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0, new ParametersAction(new StringParameterValue("BRANCH","master2"))));
Assert.assertEquals(FlowDurabilityHint.PERFORMANCE_OPTIMIZED, b.getExecution().getDurabilityHint());

assertThat(lr.getMessages(), hasItem(containsString("refs/heads/master2:refs/remotes/origin/master2")));
r.assertBuildStatusSuccess(p.scheduleBuild2(0, new ParametersAction(new StringParameterValue("BRANCH","master2"))));
}

@Issue("JENKINS-59425")
Expand Down

0 comments on commit 5e5aea3

Please sign in to comment.