From e6731c5a9e39737be611cb0bb6a7f321e98ad967 Mon Sep 17 00:00:00 2001 From: Dmitry_Platonov Date: Fri, 5 Aug 2022 11:54:07 +0300 Subject: [PATCH 1/2] don't use TimeoutStep --- .../workflow/steps/CatchErrorStepTest.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/test/java/org/jenkinsci/plugins/workflow/steps/CatchErrorStepTest.java b/src/test/java/org/jenkinsci/plugins/workflow/steps/CatchErrorStepTest.java index c6ce044c..3105b610 100644 --- a/src/test/java/org/jenkinsci/plugins/workflow/steps/CatchErrorStepTest.java +++ b/src/test/java/org/jenkinsci/plugins/workflow/steps/CatchErrorStepTest.java @@ -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); } From 6cad3f6c8d485087449e59e7594671f2a74c9249 Mon Sep 17 00:00:00 2001 From: Dmitry Platonov <47667812+Pldi23@users.noreply.github.com> Date: Fri, 5 Aug 2022 17:16:06 +0300 Subject: [PATCH 2/2] align indentation Co-authored-by: Devin Nusbaum --- .../workflow/steps/CatchErrorStepTest.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/java/org/jenkinsci/plugins/workflow/steps/CatchErrorStepTest.java b/src/test/java/org/jenkinsci/plugins/workflow/steps/CatchErrorStepTest.java index 3105b610..0721c91e 100644 --- a/src/test/java/org/jenkinsci/plugins/workflow/steps/CatchErrorStepTest.java +++ b/src/test/java/org/jenkinsci/plugins/workflow/steps/CatchErrorStepTest.java @@ -166,10 +166,10 @@ public class CatchErrorStepTest { WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p"); p.setDefinition(new CpsFlowDefinition( "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)); + "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); } @@ -178,10 +178,10 @@ public class CatchErrorStepTest { WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p"); p.setDefinition(new CpsFlowDefinition( "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)); + "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); }