Skip to content

Commit be2120f

Browse files
test: skip tests failing when run under root
PR-URL: #58610 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Pietro Marchini <[email protected]> Reviewed-By: Edy Silva <[email protected]> Reviewed-By: Stefan Stojanovic <[email protected]>
1 parent 58e1cba commit be2120f

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

test/parallel/test-config-file.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,10 @@ test('should override node.config.json when specificied', async () => {
361361
strictEqual(result.code, 0);
362362
});
363363
// Skip on windows because it doesn't support chmod changing read permissions
364-
test('should throw an error when the file is non readable', { skip: common.isWindows }, async () => {
364+
// Also skip if user is root because it would have read permissions anyway
365+
test('should throw an error when the file is non readable', {
366+
skip: common.isWindows || process.getuid() === 0,
367+
}, async () => {
365368
chmodSync(fixtures.path('rc/non-readable/node.config.json'), constants.O_RDONLY);
366369
const result = await spawnPromisified(process.execPath, [
367370
'--no-warnings',

test/parallel/test-sqlite-backup.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { skipIfSQLiteMissing } from '../common/index.mjs';
1+
import { isWindows, skipIfSQLiteMissing } from '../common/index.mjs';
22
import tmpdir from '../common/tmpdir.js';
33
import { join } from 'node:path';
44
import { describe, test } from 'node:test';
@@ -7,6 +7,8 @@ import { pathToFileURL } from 'node:url';
77
skipIfSQLiteMissing();
88
const { backup, DatabaseSync } = await import('node:sqlite');
99

10+
const isRoot = !isWindows && process.getuid() === 0;
11+
1012
let cnt = 0;
1113

1214
tmpdir.refresh();
@@ -252,7 +254,7 @@ test('throws if URL is not file: scheme', (t) => {
252254
});
253255
});
254256

255-
test('database backup fails when dest file is not writable', async (t) => {
257+
test('database backup fails when dest file is not writable', { skip: isRoot }, async (t) => {
256258
const readonlyDestDb = nextDb();
257259
writeFileSync(readonlyDestDb, '', { mode: 0o444 });
258260

0 commit comments

Comments
 (0)