Skip to content

Commit

Permalink
Merge pull request #225 from Pldi23/flakebusters
Browse files Browse the repository at this point in the history
Fix flaky CatchErrorStepTest
  • Loading branch information
dwnusbaum committed Aug 5, 2022
2 parents 6b9c830 + 6cad3f6 commit d11361f
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,26 +162,26 @@ public class CatchErrorStepTest {
assertCatchError(r, b, Result.SUCCESS, Result.UNSTABLE, true);
}

@Test public void catchesTimeoutsByDefault() throws Exception {
@Test public void catchesInterruptionsByDefault() throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition(
"timeout(time: 1, unit: 'SECONDS') {\n" +
" catchError(message: 'caught error') {\n" +
" sleep 5\n" +
" }\n" +
"}", true));
"import jenkins.model.CauseOfInterruption\n" +
"import org.jenkinsci.plugins.workflow.steps.FlowInterruptedException\n" +
"catchError(message: 'caught error') {\n" +
" throw new FlowInterruptedException(Result.ABORTED, true, new CauseOfInterruption[0])\n" +
"}", false));
WorkflowRun b = p.scheduleBuild2(0).waitForStart();
assertCatchError(r, b, Result.ABORTED, Result.ABORTED, true);
}

@Test public void canAvoidCatchingTimeoutsWithOption() throws Exception {
@Test public void canAvoidCatchingInterruptionsWithOption() throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition(
"timeout(time: 1, unit: 'SECONDS') {\n" +
" catchError(message: 'caught error', catchInterruptions: false) {\n" +
" sleep 5\n" +
" }\n" +
"}", true));
"import jenkins.model.CauseOfInterruption\n" +
"import org.jenkinsci.plugins.workflow.steps.FlowInterruptedException\n" +
"catchError(message: 'caught error', catchInterruptions: false) {\n" +
" throw new FlowInterruptedException(Result.ABORTED, true, new CauseOfInterruption[0])\n" +
"}", false));
WorkflowRun b = p.scheduleBuild2(0).waitForStart();
assertCatchError(r, b, Result.ABORTED, null, false);
}
Expand Down

0 comments on commit d11361f

Please sign in to comment.