Skip to content

Commit 0b62ffe

Browse files
committed
Test coverage for evaluateing classes across restarts
1 parent 769bb74 commit 0b62ffe

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

plugin/src/test/java/org/jenkinsci/plugins/workflow/cps/CpsFlowExecutionTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,26 @@ public boolean isAllowed(String groovyResourceUrl) {
692692
}
693693
}
694694

695+
@Test public void evaluateAfterRestart() throws Throwable {
696+
sessions.then(r -> {
697+
WorkflowJob p = r.createProject(WorkflowJob.class, "p");
698+
p.setDefinition(new CpsFlowDefinition(
699+
"def x = evaluate('class X {X() {}; def m1() {/OK/}}; new X()')\n" +
700+
"def y = evaluate('class Y {X x; def m2() {/really ${x.m1()}/}}; new Y()')\n" +
701+
"semaphore('wait')\n" +
702+
"y.x = x\n" +
703+
"echo(/received ${y.m2()}/)\n", true));
704+
WorkflowRun b = p.scheduleBuild2(0).waitForStart();
705+
SemaphoreStep.waitForStart("wait/1", b);
706+
});
707+
sessions.then(r -> {
708+
WorkflowJob p = r.jenkins.getItemByFullName("p", WorkflowJob.class);
709+
WorkflowRun b = p.getLastBuild();
710+
SemaphoreStep.success("wait/1", null);
711+
r.assertLogContains("received really OK", r.assertBuildStatus(Result.SUCCESS, r.waitForCompletion(b)));
712+
});
713+
}
714+
695715
@Issue({ "JENKINS-45327", "JENKINS-68849" })
696716
@Test public void envActionImplPickle() throws Throwable {
697717
sessions.then(r -> {

0 commit comments

Comments
 (0)