diff options
author | Leo Kettmeir <crowlkats@toaxl.com> | 2023-07-31 22:29:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-31 22:29:09 +0200 |
commit | aa8078b6888ee4d55ef348e336e076676dffc25f (patch) | |
tree | 94eb64853c52c62864cfe3d3efc08edfdfa3f63b /cli/tests/unit_node/os_test.ts | |
parent | 78ceeec6bedb521dfd2a44530bee9fea62afb289 (diff) |
feat(node/os): implement getPriority, setPriority & userInfo (#19370)
Takes #4202 over
Closes #17850
---------
Co-authored-by: ecyrbe <ecyrbe@gmail.com>
Diffstat (limited to 'cli/tests/unit_node/os_test.ts')
-rw-r--r-- | cli/tests/unit_node/os_test.ts | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/cli/tests/unit_node/os_test.ts b/cli/tests/unit_node/os_test.ts index 85164d1e6..2d0d3a8c8 100644 --- a/cli/tests/unit_node/os_test.ts +++ b/cli/tests/unit_node/os_test.ts @@ -5,6 +5,7 @@ import os from "node:os"; import { assert, assertEquals, + assertNotEquals, assertThrows, } from "../../../test_util/std/testing/asserts.ts"; @@ -252,28 +253,39 @@ Deno.test({ }); Deno.test({ - name: "APIs not yet implemented", + name: "os.setPriority() & os.getPriority()", + // disabled because os.getPriority() doesn't work without sudo + ignore: true, fn() { - assertThrows( - () => { - os.getPriority(); - }, - Error, - "Not implemented", - ); - assertThrows( - () => { - os.setPriority(0); - }, - Error, - "Not implemented", + const child = new Deno.Command(Deno.execPath(), { + args: ["eval", "while (true) { console.log('foo') }"], + }).spawn(); + const originalPriority = os.getPriority(child.pid); + assertNotEquals(originalPriority, os.constants.priority.PRIORITY_HIGH); + os.setPriority(child.pid, os.constants.priority.PRIORITY_HIGH); + assertEquals( + os.getPriority(child.pid), + os.constants.priority.PRIORITY_HIGH, ); + os.setPriority(child.pid, originalPriority); + assertEquals(os.getPriority(child.pid), originalPriority); + child.kill(); + }, +}); + +Deno.test({ + name: + "os.setPriority() throw os permission denied error & os.getPriority() doesn't", + async fn() { + const child = new Deno.Command(Deno.execPath(), { + args: ["eval", "while (true) { console.log('foo') }"], + }).spawn(); assertThrows( - () => { - os.userInfo(); - }, - Error, - "Not implemented", + () => os.setPriority(child.pid, os.constants.priority.PRIORITY_HIGH), + Deno.errors.PermissionDenied, ); + os.getPriority(child.pid); + child.kill(); + await child.status; }, }); |