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 | |
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')
-rw-r--r-- | cli/tests/integration/shared_library_tests.rs | 4 | ||||
-rw-r--r-- | cli/tests/unit_node/os_test.ts | 50 |
2 files changed, 34 insertions, 20 deletions
diff --git a/cli/tests/integration/shared_library_tests.rs b/cli/tests/integration/shared_library_tests.rs index 531fdd516..641deab4c 100644 --- a/cli/tests/integration/shared_library_tests.rs +++ b/cli/tests/integration/shared_library_tests.rs @@ -45,12 +45,14 @@ fn macos_shared_libraries() { // target/release/deno: // /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1953.255.0) // /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 1228.0.0) + // /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration (compatibility version 1.0.0, current version 1241.100.11) // /System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 60420.60.24) // /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0) // /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0) - const EXPECTED: [&str; 6] = + const EXPECTED: [&str; 7] = ["/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation", "/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices", + "/System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration", "/System/Library/Frameworks/Security.framework/Versions/A/Security", "/usr/lib/libiconv.2.dylib", "/usr/lib/libSystem.B.dylib", 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; }, }); |