Skip to content

test: skip tests failing when run under root #58610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion test/parallel/test-config-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,10 @@ test('should override node.config.json when specificied', async () => {
strictEqual(result.code, 0);
});
// Skip on windows because it doesn't support chmod changing read permissions
test('should throw an error when the file is non readable', { skip: common.isWindows }, async () => {
// Also skip if user is root because it would have read permissions anyway
test('should throw an error when the file is non readable', {
skip: common.isWindows || process.getuid() === 0,
}, async () => {
chmodSync(fixtures.path('rc/non-readable/node.config.json'), constants.O_RDONLY);
const result = await spawnPromisified(process.execPath, [
'--no-warnings',
Expand Down
6 changes: 4 additions & 2 deletions test/parallel/test-sqlite-backup.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { skipIfSQLiteMissing } from '../common/index.mjs';
import { isWindows, skipIfSQLiteMissing } from '../common/index.mjs';
import tmpdir from '../common/tmpdir.js';
import { join } from 'node:path';
import { describe, test } from 'node:test';
Expand All @@ -7,6 +7,8 @@ import { pathToFileURL } from 'node:url';
skipIfSQLiteMissing();
const { backup, DatabaseSync } = await import('node:sqlite');

const isRoot = !isWindows && process.getuid() === 0;

let cnt = 0;

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

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

Expand Down
Loading