From 6614f79fe382b87a2c2434f97fba16de45f268a6 Mon Sep 17 00:00:00 2001 From: konstapukarifastnetfi Date: Sun, 7 Jun 2026 08:25:53 +0300 Subject: [PATCH] test: skip chmod-based permission tests when running as root (#2171) Two tests provoke EACCES via chmod (saveAliases backup double failure, appendSessionContent on a read-only file) and already skip on win32, but root ignores file modes so both fail when the suite runs as root (for example in a default Docker container). Every other chmod-based test in the repo already guards with process.getuid?.() === 0; these two were the only ones missing the guard. Apply the same skip condition and message. --- tests/lib/session-aliases.test.js | 4 ++-- tests/lib/session-manager.test.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/lib/session-aliases.test.js b/tests/lib/session-aliases.test.js index 8e4b7226..11a4fa05 100644 --- a/tests/lib/session-aliases.test.js +++ b/tests/lib/session-aliases.test.js @@ -1230,8 +1230,8 @@ function runTests() { // session-aliases.js lines 131-137: When saveAliases fails (outer catch), // it tries to restore from backup. If the restore ALSO fails, the inner // catch at line 135 logs restoreErr. No existing test creates this double-fault. - if (process.platform === 'win32') { - console.log(' (skipped — chmod not reliable on Windows)'); + if (process.platform === 'win32' || process.getuid?.() === 0) { + console.log(' (skipped — chmod ineffective on Windows/root)'); return; } const isoHome = path.join(os.tmpdir(), `ecc-r90-restore-fail-${Date.now()}`); diff --git a/tests/lib/session-manager.test.js b/tests/lib/session-manager.test.js index a34447d7..bdf16417 100644 --- a/tests/lib/session-manager.test.js +++ b/tests/lib/session-manager.test.js @@ -2071,9 +2071,9 @@ file.ts // ── Round 112: appendSessionContent with read-only file — returns false ── console.log('\nRound 112: appendSessionContent (read-only file):'); if (test('appendSessionContent returns false when file is read-only (EACCES)', () => { - if (process.platform === 'win32') { - // chmod doesn't work reliably on Windows — skip - assert.ok(true, 'Skipped on Windows'); + if (process.platform === 'win32' || process.getuid?.() === 0) { + // chmod ineffective on Windows/root — skip + assert.ok(true, 'Skipped on Windows/root'); return; } const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'r112-readonly-'));