From a2bf61d1ae3ba2ff746a98ad2f0a96b6fc7782d0 Mon Sep 17 00:00:00 2001 From: uki00a Date: Wed, 8 Jul 2020 23:35:45 +0900 Subject: feat(unstable): Deno.ppid (#6539) --- cli/tests/unit/os_test.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'cli/tests/unit/os_test.ts') diff --git a/cli/tests/unit/os_test.ts b/cli/tests/unit/os_test.ts index b737d939a..e969464e5 100644 --- a/cli/tests/unit/os_test.ts +++ b/cli/tests/unit/os_test.ts @@ -111,6 +111,28 @@ unitTest(function osPid(): void { assert(Deno.pid > 0); }); +unitTest(function osPpid(): void { + assert(Deno.ppid > 0); +}); + +unitTest( + { perms: { run: true, read: true } }, + async function osPpidIsEqualToPidOfParentProcess(): Promise { + const decoder = new TextDecoder(); + const process = Deno.run({ + cmd: [Deno.execPath(), "eval", "-p", "--unstable", "Deno.ppid"], + stdout: "piped", + env: { NO_COLOR: "true" }, + }); + const output = await process.output(); + process.close(); + + const expected = Deno.pid; + const actual = parseInt(decoder.decode(output)); + assertEquals(actual, expected); + } +); + unitTest({ perms: { read: true } }, function execPath(): void { assertNotEquals(Deno.execPath(), ""); }); -- cgit v1.2.3