diff options
author | Satya Rohith <me@satyarohith.com> | 2024-02-23 19:06:17 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-23 14:36:17 +0100 |
commit | 156cfe5c90a18d838979d143046698d0ac3f1072 (patch) | |
tree | e942712d8c36be3a028070db5a7696cafd757f73 /tests/unit_node/process_test.ts | |
parent | f49abcc1ac3de72bf894ccfc0102d83ec19f1d46 (diff) |
fix(ext/node): init arch, pid, platform at startup (#22561)
Diffstat (limited to 'tests/unit_node/process_test.ts')
-rw-r--r-- | tests/unit_node/process_test.ts | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/tests/unit_node/process_test.ts b/tests/unit_node/process_test.ts index bff3c6641..24ef6a316 100644 --- a/tests/unit_node/process_test.ts +++ b/tests/unit_node/process_test.ts @@ -1,7 +1,14 @@ // deno-lint-ignore-file no-undef // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -import process, { argv, env } from "node:process"; +import process, { + arch as importedArch, + argv, + env, + pid as importedPid, + platform as importedPlatform, +} from "node:process"; + import { Readable } from "node:stream"; import { once } from "node:events"; import { @@ -83,7 +90,11 @@ Deno.test({ Deno.test({ name: "process.platform", fn() { + const expectedOs = Deno.build.os == "windows" ? "win32" : Deno.build.os; assertEquals(typeof process.platform, "string"); + assertEquals(process.platform, expectedOs); + assertEquals(typeof importedPlatform, "string"); + assertEquals(importedPlatform, expectedOs); }, }); @@ -102,14 +113,20 @@ Deno.test({ Deno.test({ name: "process.arch", fn() { - assertEquals(typeof process.arch, "string"); - if (Deno.build.arch == "x86_64") { - assertEquals(process.arch, "x64"); - } else if (Deno.build.arch == "aarch64") { - assertEquals(process.arch, "arm64"); - } else { - throw new Error("unreachable"); + function testValue(arch: string) { + if (Deno.build.arch == "x86_64") { + assertEquals(arch, "x64"); + } else if (Deno.build.arch == "aarch64") { + assertEquals(arch, "arm64"); + } else { + throw new Error("unreachable"); + } } + + assertEquals(typeof process.arch, "string"); + testValue(process.arch); + assertEquals(typeof importedArch, "string"); + testValue(importedArch); }, }); @@ -118,6 +135,8 @@ Deno.test({ fn() { assertEquals(typeof process.pid, "number"); assertEquals(process.pid, Deno.pid); + assertEquals(typeof importedPid, "number"); + assertEquals(importedPid, Deno.pid); }, }); |