Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update tests to split methods
  • Loading branch information
mbaitelman-bitburst-ops committed Jan 24, 2022
commit 06ef199806ec0309a41d7b5093c4613d1301f943
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,19 @@ public class PowerShellStepTest {
p.setDefinition(new CpsFlowDefinition("node {powershell 'throw \"bogus error\"'}", true));
j.assertLogContains("bogus error", j.assertBuildStatus(Result.FAILURE, p.scheduleBuild2(0)));
}

// Test that a powershell step that fails indeed causes the underlying build to fail with stopOnError: true
@Test public void testStopOnFailure() throws Exception {
WorkflowJob p = j.jenkins.createProject(WorkflowJob.class, "stopOnError");
p.setDefinition(new CpsFlowDefinition("node {powershell( script: 'throw \"bogus error\"; Write-output \"We made it past the error\"', stopOnError: true)}", true));
p.setDefinition(new CpsFlowDefinition("node {powershell( script: 'throw \"bogus error\"', stopOnError: true) powershell( script: 'Write-output \"We made it past the error\"') }", true));
j.assertLogNotContains("We made it past the error", j.assertBuildStatus(Result.FAILURE, p.scheduleBuild2(0)));
j.assertLogContains("bogus error", j.assertBuildStatus(Result.FAILURE, p.scheduleBuild2(0)));
}

// Test that a powershell step that fails does not cause the underlying build to fail with stopOnError: false
@Test public void testStopOnFailureFalse() throws Exception {
WorkflowJob p = j.jenkins.createProject(WorkflowJob.class, "stopOnErrorFalse");
p.setDefinition(new CpsFlowDefinition("node {powershell( script: 'throw \"bogus error\"; Write-output \"We made it past the error\"', stopOnError: false)}", true));
p.setDefinition(new CpsFlowDefinition("node {powershell( script: 'throw \"bogus error\"', stopOnError: false) powershell( script: 'Write-output \"We made it past the error\"') }", true));
j.assertLogContains("We made it past the error", j.assertBuildStatus(Result.FAILURE, p.scheduleBuild2(0)));
j.assertLogContains("bogus error", j.assertBuildStatus(Result.FAILURE, p.scheduleBuild2(0)));
}
Expand Down