From 5019eb900cc3e39590249f8d20ffc87310b96821 Mon Sep 17 00:00:00 2001 From: Devin Nusbaum Date: Tue, 15 Oct 2024 17:36:47 -0400 Subject: [PATCH] Stop build in `DeleteBuildsCommandTest.deleteBuildsShouldFailIfTheBuildIsRunning` so test can be cleaned up on Windows consistently (#9876) --- test/src/test/java/hudson/cli/DeleteBuildsCommandTest.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/src/test/java/hudson/cli/DeleteBuildsCommandTest.java b/test/src/test/java/hudson/cli/DeleteBuildsCommandTest.java index 5e2e917e9808..08e6552f610e 100644 --- a/test/src/test/java/hudson/cli/DeleteBuildsCommandTest.java +++ b/test/src/test/java/hudson/cli/DeleteBuildsCommandTest.java @@ -36,6 +36,7 @@ import hudson.model.ExecutorTest; import hudson.model.FreeStyleProject; import hudson.model.Item; +import hudson.model.Result; import hudson.model.Run; import hudson.model.labels.LabelAtom; import hudson.tasks.Shell; @@ -139,7 +140,7 @@ public class DeleteBuildsCommandTest { @Issue("JENKINS-73835") @Test public void deleteBuildsShouldFailIfTheBuildIsRunning() throws Exception { FreeStyleProject project = j.createFreeStyleProject("aProject"); - ExecutorTest.startBlockingBuild(project); + var build = ExecutorTest.startBlockingBuild(project); assertThat(((FreeStyleProject) j.jenkins.getItem("aProject")).getBuilds(), hasSize(1)); final CLICommandInvoker.Result result = command @@ -148,6 +149,9 @@ public class DeleteBuildsCommandTest { assertThat(result, failedWith(1)); assertThat(result, hasNoStandardOutput()); assertThat(result.stderr(), containsString("Unable to delete aProject #1 because it is still running")); + + build.doStop(); + j.assertBuildStatus(Result.ABORTED, j.waitForCompletion(build)); } @Test public void deleteBuildsShouldSuccessEvenTheBuildIsStuckInTheQueue() throws Exception {