Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion tests/specs/task/signals/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"timeout": 60,
"timeout": 45,
// signals don't really exist on windows
"if": "unix",
// this runs a deno task
Expand Down
43 changes: 33 additions & 10 deletions tests/specs/task/signals/sender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,39 @@ const command = new Deno.Command(Deno.execPath(), {

const child = command.spawn();
const reader = new StdoutReader(child.stdout!);
await reader.waitForText("Ready");

for (const signal of signals) {
if (signal === "SIGTERM") {
continue;
// Hard timeout: if anything hangs, SIGKILL the child (uncatchable) and fail.
// This prevents the test from hanging for 30m waiting on CI timeout, since
// the listener intercepts all signals including SIGTERM.
const hardTimeout = setTimeout(() => {
console.error("Test timed out, sending SIGKILL to child");
try {
child.kill("SIGKILL");
} catch {
// child may have already exited
}
console.error("Sending", signal);
child.kill(signal);
await reader.waitForText("Received " + signal);
}
Deno.exit(1);
}, 30_000);

try {
await reader.waitForText("Ready");

console.error("Sending SIGTERM");
child.kill("SIGTERM");
for (const signal of signals) {
if (signal === "SIGTERM") {
continue;
}
console.error("Sending", signal);
child.kill(signal);
await reader.waitForText("Received " + signal);
}

console.error("Sending SIGTERM");
child.kill("SIGTERM");
const status = await child.status;
if (!status.success) {
console.error("Child exited with code", status.code);
Deno.exit(1);
}
} finally {
clearTimeout(hardTimeout);
}
Loading