mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
test: use relative paths within test directory in test-watch-mode.mjs
Signed-off-by: LiviaMedeiros <livia@cirno.name> PR-URL: https://github.com/nodejs/node/pull/67343 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
This commit is contained in:
1 parent
fb4695aff8
commit
86cbf80be2
1 file changed
+9
-10
@@ -1,7 +1,6 @@
|
||||
import * as common from '../common/index.mjs';
|
||||
import tmpdir from '../common/tmpdir.js';
|
||||
import assert from 'node:assert';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { execPath } from 'node:process';
|
||||
import { describe, it } from 'node:test';
|
||||
@@ -1093,19 +1092,18 @@ process.on('message', (message) => {
|
||||
// Honoring --require from NODE_OPTIONS is required for this test.
|
||||
skip: !!process.config.variables.node_without_node_options,
|
||||
}, async () => {
|
||||
// Use /tmp to avoid CI directories with special characters (e.g. ")
|
||||
// Use relative path to avoid CI directories with special characters (e.g. ")
|
||||
// that would break NODE_OPTIONS parsing.
|
||||
const watchDir = path.join(os.tmpdir(), 'test for --watch parsing');
|
||||
mkdirSync(watchDir, { recursive: true });
|
||||
const reqFile = path.join(watchDir, 'req.cjs');
|
||||
const reqFile = tmpdir.resolve('req.cjs');
|
||||
writeFileSync(reqFile, 'globalThis.requiredOk = true;');
|
||||
|
||||
const file = createTmpFile('console.log("required:" + !!globalThis.requiredOk);');
|
||||
// Backslashes inside quoted NODE_OPTIONS values are escape characters.
|
||||
const nodeOptions = `--watch --require "${reqFile.replaceAll(path.sep, '/')}"`;
|
||||
const nodeOptions = '--watch --require ./req.cjs';
|
||||
const { done, restart } = runInBackground({
|
||||
args: ['--watch', file],
|
||||
options: {
|
||||
cwd: tmpdir.path,
|
||||
env: { ...process.env, NODE_OPTIONS: nodeOptions },
|
||||
},
|
||||
});
|
||||
@@ -1170,16 +1168,17 @@ process.on('message', (message) => {
|
||||
|
||||
it('should strip multiple --watch-path entries from NODE_OPTIONS', async () => {
|
||||
const file = createTmpFile('console.log(process.env.NODE_OPTIONS);');
|
||||
// Use /tmp to avoid CI directories with special characters (e.g. ")
|
||||
// Use relative path to avoid CI directories with special characters (e.g. ")
|
||||
// that would break NODE_OPTIONS parsing.
|
||||
const dirA = path.join(os.tmpdir(), 'node-watch-path-a');
|
||||
const dirB = path.join(os.tmpdir(), 'node-watch-path-b');
|
||||
const dirA = tmpdir.resolve('node-watch-path-a');
|
||||
const dirB = tmpdir.resolve('node-watch-path-b');
|
||||
mkdirSync(dirA, { recursive: true });
|
||||
mkdirSync(dirB, { recursive: true });
|
||||
const nodeOptions = `--watch --watch-path=${dirA} --watch-path ${dirB} --no-warnings`;
|
||||
const nodeOptions = '--watch --watch-path=./node-watch-path-a --watch-path ./node-watch-path-b --no-warnings';
|
||||
const { done, restart } = runInBackground({
|
||||
args: ['--watch', file],
|
||||
options: {
|
||||
cwd: tmpdir.path,
|
||||
env: { ...process.env, NODE_OPTIONS: nodeOptions },
|
||||
},
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user