From f460188e583f00144000aa0d8ade08218d47c3c1 Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Thu, 19 Sep 2024 12:22:01 +0900 Subject: fix(ext/node): don't throw error for unsupported signal binding on windows (#25699) --- tests/unit_node/process_test.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests/unit_node') diff --git a/tests/unit_node/process_test.ts b/tests/unit_node/process_test.ts index 944686a87..add9e1280 100644 --- a/tests/unit_node/process_test.ts +++ b/tests/unit_node/process_test.ts @@ -25,6 +25,7 @@ import { assertThrows, fail, } from "@std/assert"; +import { assertSpyCall, assertSpyCalls, spy } from "@std/testing/mock"; import { stripAnsiCode } from "@std/fmt/colors"; import * as path from "@std/path"; import { delay } from "@std/async/delay"; @@ -238,6 +239,33 @@ Deno.test({ }, }); +Deno.test({ + name: "process.on - ignored signals on windows", + ignore: Deno.build.os !== "windows", + fn() { + const ignoredSignals = ["SIGHUP", "SIGUSR1", "SIGUSR2"]; + + for (const signal of ignoredSignals) { + using consoleSpy = spy(console, "warn"); + const handler = () => {}; + process.on(signal, handler); + process.off(signal, handler); + assertSpyCall(consoleSpy, 0, { + args: [`Ignoring signal "${signal}" on Windows`], + }); + } + + { + using consoleSpy = spy(console, "warn"); + const handler = () => {}; + process.on("SIGTERM", handler); + process.off("SIGTERM", handler); + // No warning is made for SIGTERM + assertSpyCalls(consoleSpy, 0); + } + }, +}); + Deno.test( { permissions: { run: true, read: true } }, async function processKill() { -- cgit v1.2.3