mirror of
https://github.com/nodejs/node.git
synced 2026-11-15 10:36:53 -05:00
test: save the config file in a temporary directory
Allow the test to be run in parallel. Refs: https://github.com/nodejs/node/pull/58799#issuecomment-2995684216 PR-URL: https://github.com/nodejs/node/pull/58799 Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com> Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com> Reviewed-By: Ethan Arrowood <ethan@arrowood.dev> Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
This commit is contained in:
1 parent
cd685fe3b6
commit
100c6da238
2 files changed
+16
-13
No files matched your search
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"nodeOptions": {
|
||||
"max-http-header-size": 10
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
const { spawnPromisified, skipIfSQLiteMissing } = require('../common');
|
||||
const {
|
||||
isWindows,
|
||||
spawnPromisified,
|
||||
skipIfSQLiteMissing,
|
||||
} = require('../common');
|
||||
skipIfSQLiteMissing();
|
||||
const fixtures = require('../common/fixtures');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const { match, strictEqual, deepStrictEqual } = require('node:assert');
|
||||
const { test, it, describe } = require('node:test');
|
||||
const { chmodSync, constants } = require('node:fs');
|
||||
const common = require('../common');
|
||||
const { chmodSync, writeFileSync, constants } = require('node:fs');
|
||||
const { join } = require('node:path');
|
||||
|
||||
test('should handle non existing json', async () => {
|
||||
const result = await spawnPromisified(process.execPath, [
|
||||
@@ -364,21 +369,24 @@ test('should override node.config.json when specificied', async () => {
|
||||
// Skip on windows because it doesn't support chmod changing read permissions
|
||||
// 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,
|
||||
skip: isWindows || process.getuid() === 0,
|
||||
}, async () => {
|
||||
chmodSync(fixtures.path('rc/non-readable/node.config.json'), constants.O_RDONLY);
|
||||
tmpdir.refresh();
|
||||
const dest = join(tmpdir.path, 'node.config.json');
|
||||
writeFileSync(dest, JSON.stringify({
|
||||
nodeOptions: { 'max-http-header-size': 10 }
|
||||
}));
|
||||
chmodSync(dest, constants.O_RDONLY);
|
||||
const result = await spawnPromisified(process.execPath, [
|
||||
'--no-warnings',
|
||||
'--experimental-default-config-file',
|
||||
'-p', 'http.maxHeaderSize',
|
||||
], {
|
||||
cwd: fixtures.path('rc/non-readable'),
|
||||
cwd: tmpdir.path,
|
||||
});
|
||||
match(result.stderr, /Cannot read configuration from node\.config\.json: permission denied/);
|
||||
strictEqual(result.stdout, '');
|
||||
strictEqual(result.code, 9);
|
||||
chmodSync(fixtures.path('rc/non-readable/node.config.json'),
|
||||
constants.S_IRWXU | constants.S_IRWXG | constants.S_IRWXO);
|
||||
});
|
||||
|
||||
describe('namespace-scoped options', () => {
|
||||
|
||||
Reference in new issue
Block a user