Skip to content

Commit 914c87c

Browse files
committed
test(harness): wait for the cancelled task's worker before cleanup
cancellingRunningBackgroundSpawnStopsTheChild returned as soon as the child was cancelled. The repository worker then still wrote the CANCELLED record into the temporary workspace, so JUnit could delete the directory while the record was being written and fail with DirectoryNotEmptyException, as seen on the Ubuntu CI runner. Shut the executor down and wait for it after the child stops, as the repository-level cancellation tests already do.
1 parent a3730bc commit 914c87c

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎agentscope-harness/src/test/java/io/agentscope/harness/agent/tool/AgentSpawnToolLifecycleTest.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,10 @@ private static void assertTaskCancellationStopsChild(
676676
assertTrue(
677677
childCancelled.await(10, TimeUnit.SECONDS),
678678
"cancelling the background task must stop the running child");
679+
// The worker records the cancellation after the child stops. Wait for it, so the
680+
// temporary workspace is not deleted while the record is still being written.
681+
executor.shutdown();
682+
assertTrue(executor.awaitTermination(10, TimeUnit.SECONDS));
679683
} finally {
680684
executor.shutdownNow();
681685
}

0 commit comments

Comments
 (0)