From f60cc5871b3950a078356dbd30cb16ba64890916 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Fri, 15 Nov 2024 09:21:46 +0100 Subject: [PATCH] test: skip `setPriority` test if insufficient permissions --- test/parallel/test-os.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-os.js b/test/parallel/test-os.js index efaec2b3ead385..0a83170d92a48f 100644 --- a/test/parallel/test-os.js +++ b/test/parallel/test-os.js @@ -85,10 +85,16 @@ assert.ok(hostname.length > 0); if (!common.isIBMi) { const { PRIORITY_BELOW_NORMAL, PRIORITY_LOW } = os.constants.priority; const LOWER_PRIORITY = os.getPriority() > PRIORITY_BELOW_NORMAL ? PRIORITY_BELOW_NORMAL : PRIORITY_LOW; - os.setPriority(LOWER_PRIORITY); - const priority = os.getPriority(); - is.number(priority); - assert.strictEqual(priority, LOWER_PRIORITY); + try { + os.setPriority(LOWER_PRIORITY); + const priority = os.getPriority(); + is.number(priority); + assert.strictEqual(priority, LOWER_PRIORITY); + } catch (err) { + // The current user might not have sufficient permissions to set this + // specific priority level. + if (err?.info?.code !== 'EACCES') throw err; + } } // On IBMi, os.uptime() returns 'undefined'