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.
This commit is contained in:
konstapukarifastnetfi
2026-06-07 08:25:53 +03:00
committed by GitHub
parent b189e8ec9f
commit 6614f79fe3
2 changed files with 5 additions and 5 deletions
+2 -2
View File
@@ -1230,8 +1230,8 @@ function runTests() {
// session-aliases.js lines 131-137: When saveAliases fails (outer catch), // session-aliases.js lines 131-137: When saveAliases fails (outer catch),
// it tries to restore from backup. If the restore ALSO fails, the inner // 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. // catch at line 135 logs restoreErr. No existing test creates this double-fault.
if (process.platform === 'win32') { if (process.platform === 'win32' || process.getuid?.() === 0) {
console.log(' (skipped — chmod not reliable on Windows)'); console.log(' (skipped — chmod ineffective on Windows/root)');
return; return;
} }
const isoHome = path.join(os.tmpdir(), `ecc-r90-restore-fail-${Date.now()}`); const isoHome = path.join(os.tmpdir(), `ecc-r90-restore-fail-${Date.now()}`);
+3 -3
View File
@@ -2071,9 +2071,9 @@ file.ts
// ── Round 112: appendSessionContent with read-only file — returns false ── // ── Round 112: appendSessionContent with read-only file — returns false ──
console.log('\nRound 112: appendSessionContent (read-only file):'); console.log('\nRound 112: appendSessionContent (read-only file):');
if (test('appendSessionContent returns false when file is read-only (EACCES)', () => { if (test('appendSessionContent returns false when file is read-only (EACCES)', () => {
if (process.platform === 'win32') { if (process.platform === 'win32' || process.getuid?.() === 0) {
// chmod doesn't work reliably on Windows — skip // chmod ineffective on Windows/root — skip
assert.ok(true, 'Skipped on Windows'); assert.ok(true, 'Skipped on Windows/root');
return; return;
} }
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'r112-readonly-')); const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'r112-readonly-'));