summaryrefslogtreecommitdiff
path: root/cli/tests/unit/command_test.ts
diff options
context:
space:
mode:
authorLuca Casonato <hello@lcas.dev>2023-11-01 20:26:12 +0100
committerGitHub <noreply@github.com>2023-11-01 20:26:12 +0100
commitd42f1543121e7245789a96a485d1ef7645cb5fba (patch)
treed57a10ac527fe5b6796a3a8866af95f0f1a5d7bd /cli/tests/unit/command_test.ts
parent1d19b1011bd7df50598f5981408c2d78c35b76d2 (diff)
feat: disposable Deno resources (#20845)
This commit implements Symbol.dispose and Symbol.asyncDispose for the relevant resources. Closes #20839 --------- Signed-off-by: Bartek Iwańczuk <biwanczuk@gmail.com> Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Diffstat (limited to 'cli/tests/unit/command_test.ts')
-rw-r--r--cli/tests/unit/command_test.ts40
1 files changed, 40 insertions, 0 deletions
diff --git a/cli/tests/unit/command_test.ts b/cli/tests/unit/command_test.ts
index 5f56a0c22..299c70b9b 100644
--- a/cli/tests/unit/command_test.ts
+++ b/cli/tests/unit/command_test.ts
@@ -258,6 +258,46 @@ Deno.test(
Deno.test(
{ permissions: { run: true, read: true } },
+ // deno lint bug, see https://github.com/denoland/deno_lint/issues/1206
+ // deno-lint-ignore require-await
+ async function childProcessExplicitResourceManagement() {
+ let dead = undefined;
+ {
+ const command = new Deno.Command(Deno.execPath(), {
+ args: ["eval", "setTimeout(() => {}, 10000)"],
+ stdout: "null",
+ stderr: "null",
+ });
+ await using child = command.spawn();
+ child.status.then(({ signal }) => {
+ dead = signal;
+ });
+ }
+
+ if (Deno.build.os == "windows") {
+ assertEquals(dead, null);
+ } else {
+ assertEquals(dead, "SIGTERM");
+ }
+ },
+);
+
+Deno.test(
+ { permissions: { run: true, read: true } },
+ async function childProcessExplicitResourceManagementManualClose() {
+ const command = new Deno.Command(Deno.execPath(), {
+ args: ["eval", "setTimeout(() => {}, 10000)"],
+ stdout: "null",
+ stderr: "null",
+ });
+ await using child = command.spawn();
+ child.kill("SIGTERM");
+ await child.status;
+ },
+);
+
+Deno.test(
+ { permissions: { run: true, read: true } },
async function commandKillFailed() {
const command = new Deno.Command(Deno.execPath(), {
args: ["eval", "setTimeout(() => {}, 5000)"],