mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
test: use tmpdir.resolve()
PR-URL: https://github.com/nodejs/node/pull/49128 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This commit is contained in:
@@ -27,7 +27,6 @@ const tmpdir = require('../common/tmpdir');
|
||||
const assert = require('assert');
|
||||
const { execFile } = require('child_process');
|
||||
const { writeFileSync, existsSync } = require('fs');
|
||||
const { join } = require('path');
|
||||
|
||||
// Test for leaked global detection
|
||||
{
|
||||
@@ -134,7 +133,7 @@ const HIJACK_TEST_ARRAY = [ 'foo\n', 'bar\n', 'baz\n' ];
|
||||
{
|
||||
tmpdir.refresh();
|
||||
assert.match(tmpdir.path, /\.tmp\.\d+/);
|
||||
const sentinelPath = join(tmpdir.path, 'gaga');
|
||||
const sentinelPath = tmpdir.resolve('gaga');
|
||||
writeFileSync(sentinelPath, 'googoo');
|
||||
tmpdir.refresh();
|
||||
assert.strictEqual(existsSync(tmpdir.path), true);
|
||||
|
||||
@@ -6,13 +6,12 @@ common.skipIfInspectorDisabled();
|
||||
const fixtures = require('../common/fixtures');
|
||||
const startCLI = require('../common/debugger');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const path = require('path');
|
||||
|
||||
tmpdir.refresh();
|
||||
|
||||
const { readFileSync } = require('fs');
|
||||
|
||||
const filename = path.join(tmpdir.path, 'node.heapsnapshot');
|
||||
const filename = tmpdir.resolve('node.heapsnapshot');
|
||||
|
||||
// Heap profiler take snapshot.
|
||||
{
|
||||
|
||||
@@ -23,10 +23,9 @@
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const fn = path.join(tmpdir.path, 'write.txt');
|
||||
const fn = tmpdir.resolve('write.txt');
|
||||
tmpdir.refresh();
|
||||
const file = fs.createWriteStream(fn, {
|
||||
highWaterMark: 10
|
||||
|
||||
@@ -23,13 +23,12 @@
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
|
||||
const filepath = path.join(tmpdir.path, 'write.txt');
|
||||
const filepath = tmpdir.resolve('write.txt');
|
||||
|
||||
const EXPECTED = '012345678910';
|
||||
|
||||
|
||||
@@ -22,13 +22,12 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
|
||||
const filepath = path.join(tmpdir.path, 'write_pos.txt');
|
||||
const filepath = tmpdir.resolve('write_pos.txt');
|
||||
|
||||
|
||||
const cb_expected = 'write open close write open close write open close ';
|
||||
|
||||
@@ -4,13 +4,12 @@
|
||||
// Refs: https://github.com/nodejs/node/issues/31366
|
||||
|
||||
const common = require('../common');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
const filepath = path.join(tmpdir.path, 'write_pos.txt');
|
||||
const filepath = tmpdir.resolve('write_pos.txt');
|
||||
|
||||
const fileReadStream = fs.createReadStream(process.execPath);
|
||||
const fileWriteStream = fs.createWriteStream(filepath, {
|
||||
|
||||
@@ -9,7 +9,6 @@ common.skipIfInspectorDisabled();
|
||||
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { spawnSync } = require('child_process');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
@@ -24,7 +23,7 @@ const {
|
||||
// Tests absolute --heap-prof-dir
|
||||
{
|
||||
tmpdir.refresh();
|
||||
const dir = path.join(tmpdir.path, 'prof');
|
||||
const dir = tmpdir.resolve('prof');
|
||||
const output = spawnSync(process.execPath, [
|
||||
'--heap-prof',
|
||||
'--heap-prof-dir',
|
||||
|
||||
@@ -23,7 +23,7 @@ const {
|
||||
|
||||
{
|
||||
tmpdir.refresh();
|
||||
const dir = path.join(tmpdir.path, 'prof');
|
||||
const dir = tmpdir.resolve('prof');
|
||||
const file = path.join(dir, 'test.heapprofile');
|
||||
const output = spawnSync(process.execPath, [
|
||||
'--heap-prof',
|
||||
|
||||
@@ -9,7 +9,6 @@ common.skipIfInspectorDisabled();
|
||||
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { spawnSync } = require('child_process');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
@@ -38,7 +37,7 @@ const {
|
||||
console.log(output.stderr.toString());
|
||||
}
|
||||
assert.strictEqual(output.status, 0);
|
||||
const dir = path.join(tmpdir.path, 'prof');
|
||||
const dir = tmpdir.resolve('prof');
|
||||
assert(fs.existsSync(dir));
|
||||
const profiles = getHeapProfiles(dir);
|
||||
assert.strictEqual(profiles.length, 1);
|
||||
|
||||
@@ -9,7 +9,6 @@ common.skipIfInspectorDisabled();
|
||||
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { spawnSync } = require('child_process');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
@@ -38,7 +37,7 @@ const {
|
||||
console.log(output.stderr.toString());
|
||||
}
|
||||
assert.strictEqual(output.status, 0);
|
||||
const dir = path.join(tmpdir.path, 'prof');
|
||||
const dir = tmpdir.resolve('prof');
|
||||
assert(fs.existsSync(dir));
|
||||
const profiles = getHeapProfiles(dir);
|
||||
assert.strictEqual(profiles.length, 2);
|
||||
|
||||
@@ -8,7 +8,6 @@ const fixtures = require('../common/fixtures');
|
||||
common.skipIfInspectorDisabled();
|
||||
|
||||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
const { spawnSync } = require('child_process');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
@@ -22,7 +21,7 @@ const {
|
||||
|
||||
{
|
||||
tmpdir.refresh();
|
||||
const file = path.join(tmpdir.path, 'test.heapprofile');
|
||||
const file = tmpdir.resolve('test.heapprofile');
|
||||
const output = spawnSync(process.execPath, [
|
||||
'--heap-prof',
|
||||
'--heap-prof-name',
|
||||
|
||||
@@ -4,13 +4,12 @@
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const SyncWriteStream = require('internal/fs/sync_write_stream');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
const filename = path.join(tmpdir.path, 'sync-write-stream.txt');
|
||||
const filename = tmpdir.resolve('sync-write-stream.txt');
|
||||
|
||||
// Verify constructing the instance with default options.
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ const nodeBinary = process.execPath;
|
||||
|
||||
tmpdir.refresh();
|
||||
|
||||
const appBundlePath = path.join(tmpdir.path, 'node_sandboxed.app');
|
||||
const appBundlePath = tmpdir.resolve('node_sandboxed.app');
|
||||
const appBundleContentPath = path.join(appBundlePath, 'Contents');
|
||||
const appExecutablePath = path.join(
|
||||
appBundleContentPath, 'MacOS', 'node');
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
const filePath = path.join(tmpdir.path, 'test-module-cache.json');
|
||||
const filePath = tmpdir.resolve('test-module-cache.json');
|
||||
assert.throws(
|
||||
() => require(filePath),
|
||||
{ code: 'MODULE_NOT_FOUND' }
|
||||
|
||||
@@ -18,7 +18,7 @@ if (process.argv[2] === 'child') {
|
||||
tmpdir.refresh();
|
||||
|
||||
// Copy node binary into a test $PREFIX directory.
|
||||
const prefixPath = path.join(tmpdir.path, 'install');
|
||||
const prefixPath = tmpdir.resolve('install');
|
||||
fs.mkdirSync(prefixPath);
|
||||
let testExecPath;
|
||||
if (common.isWindows) {
|
||||
@@ -46,7 +46,7 @@ if (process.argv[2] === 'child') {
|
||||
delete env.NODE_PATH;
|
||||
|
||||
// Test empty global path.
|
||||
const noPkgHomeDir = path.join(tmpdir.path, 'home-no-pkg');
|
||||
const noPkgHomeDir = tmpdir.resolve('home-no-pkg');
|
||||
fs.mkdirSync(noPkgHomeDir);
|
||||
env.HOME = env.USERPROFILE = noPkgHomeDir;
|
||||
assert.throws(
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const Module = require('module');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const file = path.join(tmpdir.path, 'test-extensions.foo.bar');
|
||||
const dotfile = path.join(tmpdir.path, '.bar');
|
||||
const dotfileWithExtension = path.join(tmpdir.path, '.foo.bar');
|
||||
const file = tmpdir.resolve('test-extensions.foo.bar');
|
||||
const dotfile = tmpdir.resolve('.bar');
|
||||
const dotfileWithExtension = tmpdir.resolve('.foo.bar');
|
||||
|
||||
tmpdir.refresh();
|
||||
fs.writeFileSync(file, 'console.log(__filename);', 'utf8');
|
||||
@@ -20,7 +19,7 @@ fs.writeFileSync(dotfileWithExtension, 'console.log(__filename);', 'utf8');
|
||||
{
|
||||
require.extensions['.bar'] = common.mustNotCall();
|
||||
require.extensions['.foo.bar'] = common.mustCall();
|
||||
const modulePath = path.join(tmpdir.path, 'test-extensions');
|
||||
const modulePath = tmpdir.resolve('test-extensions');
|
||||
require(modulePath);
|
||||
require(file);
|
||||
delete require.cache[file];
|
||||
@@ -31,7 +30,7 @@ fs.writeFileSync(dotfileWithExtension, 'console.log(__filename);', 'utf8');
|
||||
|
||||
{
|
||||
require.extensions['.foo.bar'] = common.mustCall();
|
||||
const modulePath = path.join(tmpdir.path, 'test-extensions');
|
||||
const modulePath = tmpdir.resolve('test-extensions');
|
||||
require(modulePath);
|
||||
assert.throws(
|
||||
() => require(`${modulePath}.foo`),
|
||||
@@ -44,7 +43,7 @@ fs.writeFileSync(dotfileWithExtension, 'console.log(__filename);', 'utf8');
|
||||
}
|
||||
|
||||
{
|
||||
const modulePath = path.join(tmpdir.path, 'test-extensions');
|
||||
const modulePath = tmpdir.resolve('test-extensions');
|
||||
assert.throws(
|
||||
() => require(modulePath),
|
||||
(err) => err.message.startsWith(`Cannot find module '${modulePath}'`)
|
||||
@@ -56,7 +55,7 @@ fs.writeFileSync(dotfileWithExtension, 'console.log(__filename);', 'utf8');
|
||||
{
|
||||
require.extensions['.bar'] = common.mustNotCall();
|
||||
require.extensions['.foo.bar'] = common.mustCall();
|
||||
const modulePath = path.join(tmpdir.path, 'test-extensions.foo');
|
||||
const modulePath = tmpdir.resolve('test-extensions.foo');
|
||||
require(modulePath);
|
||||
delete require.cache[file];
|
||||
delete require.extensions['.bar'];
|
||||
@@ -66,7 +65,7 @@ fs.writeFileSync(dotfileWithExtension, 'console.log(__filename);', 'utf8');
|
||||
|
||||
{
|
||||
require.extensions['.foo.bar'] = common.mustNotCall();
|
||||
const modulePath = path.join(tmpdir.path, 'test-extensions.foo');
|
||||
const modulePath = tmpdir.resolve('test-extensions.foo');
|
||||
assert.throws(
|
||||
() => require(modulePath),
|
||||
(err) => err.message.startsWith(`Cannot find module '${modulePath}'`)
|
||||
|
||||
@@ -16,7 +16,7 @@ const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
// Create readOnlyMod.js and set to read only
|
||||
const readOnlyMod = path.join(tmpdir.path, 'readOnlyMod');
|
||||
const readOnlyMod = tmpdir.resolve('readOnlyMod');
|
||||
const readOnlyModRelative = path.relative(__dirname, readOnlyMod);
|
||||
const readOnlyModFullPath = `${readOnlyMod}.js`;
|
||||
|
||||
|
||||
@@ -7,11 +7,10 @@ const Module = require('module');
|
||||
const fs = require('fs');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const { ok, strictEqual } = require('assert');
|
||||
const { join } = require('path');
|
||||
|
||||
const directory = join(tmpdir.path, 'directory');
|
||||
const doesNotExist = join(tmpdir.path, 'does-not-exist');
|
||||
const file = join(tmpdir.path, 'file.js');
|
||||
const directory = tmpdir.resolve('directory');
|
||||
const doesNotExist = tmpdir.resolve('does-not-exist');
|
||||
const file = tmpdir.resolve('file.js');
|
||||
|
||||
tmpdir.refresh();
|
||||
fs.writeFileSync(file, "module.exports = { a: 'b' }");
|
||||
|
||||
@@ -11,11 +11,11 @@ const fixtures = require('../common/fixtures');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
const npmSandbox = path.join(tmpdir.path, 'npm-sandbox');
|
||||
const npmSandbox = tmpdir.resolve('npm-sandbox');
|
||||
fs.mkdirSync(npmSandbox);
|
||||
const homeDir = path.join(tmpdir.path, 'home');
|
||||
const homeDir = tmpdir.resolve('home');
|
||||
fs.mkdirSync(homeDir);
|
||||
const installDir = path.join(tmpdir.path, 'install-dir');
|
||||
const installDir = tmpdir.resolve('install-dir');
|
||||
fs.mkdirSync(installDir);
|
||||
|
||||
const npmPath = path.join(
|
||||
|
||||
@@ -19,9 +19,9 @@ const { spawnSync } = require('child_process');
|
||||
tmpdir.refresh();
|
||||
}
|
||||
|
||||
const readOnlyFolder = path.join(tmpdir.path, 'read-only');
|
||||
const readWriteFolder = path.join(tmpdir.path, 'read-write');
|
||||
const writeOnlyFolder = path.join(tmpdir.path, 'write-only');
|
||||
const readOnlyFolder = tmpdir.resolve('read-only');
|
||||
const readWriteFolder = tmpdir.resolve('read-write');
|
||||
const writeOnlyFolder = tmpdir.resolve('write-only');
|
||||
const file = fixtures.path('permission', 'fs-symlink-target-write.js');
|
||||
const commonPathWildcard = path.join(__filename, '../../common*');
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ const tmpdir = require('../common/tmpdir');
|
||||
const file = fixtures.path('permission', 'fs-symlink.js');
|
||||
const commonPathWildcard = path.join(__filename, '../../common*');
|
||||
const blockedFile = fixtures.path('permission', 'deny', 'protected-file.md');
|
||||
const blockedFolder = path.join(tmpdir.path, 'subdirectory');
|
||||
const symlinkFromBlockedFile = path.join(tmpdir.path, 'example-symlink.md');
|
||||
const blockedFolder = tmpdir.resolve('subdirectory');
|
||||
const symlinkFromBlockedFile = tmpdir.resolve('example-symlink.md');
|
||||
|
||||
{
|
||||
tmpdir.refresh();
|
||||
|
||||
@@ -18,7 +18,7 @@ const tmpdir = require('../common/tmpdir');
|
||||
|
||||
const file = fixtures.path('permission', 'fs-traversal.js');
|
||||
const blockedFolder = tmpdir.path;
|
||||
const allowedFolder = path.join(tmpdir.path, 'subdirectory/');
|
||||
const allowedFolder = tmpdir.resolve('subdirectory/');
|
||||
const commonPathWildcard = path.join(__filename, '../../common*');
|
||||
|
||||
{
|
||||
|
||||
@@ -24,12 +24,11 @@ const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const http = require('http');
|
||||
const path = require('path');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
const filename = path.join(tmpdir.path, 'big');
|
||||
const filename = tmpdir.resolve('big');
|
||||
let count = 0;
|
||||
|
||||
const server = http.createServer((req, res) => {
|
||||
|
||||
@@ -20,7 +20,7 @@ function hash(algo, body) {
|
||||
return h.digest('base64');
|
||||
}
|
||||
|
||||
const tmpdirPath = path.join(tmpdir.path, 'test-policy-parse-integrity');
|
||||
const tmpdirPath = tmpdir.resolve('test-policy-parse-integrity');
|
||||
fs.rmSync(tmpdirPath, { maxRetries: 3, recursive: true, force: true });
|
||||
fs.mkdirSync(tmpdirPath, { recursive: true });
|
||||
|
||||
|
||||
@@ -7,19 +7,18 @@ require('../common');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const assert = require('assert');
|
||||
const { join } = require('path');
|
||||
const { spawnSync } = require('child_process');
|
||||
const fs = require('fs');
|
||||
|
||||
tmpdir.refresh();
|
||||
|
||||
fs.writeFileSync(
|
||||
join(tmpdir.path, 'preload.js'),
|
||||
tmpdir.resolve('preload.js'),
|
||||
'console.log(JSON.stringify(process.argv));',
|
||||
'utf-8');
|
||||
|
||||
fs.writeFileSync(
|
||||
join(tmpdir.path, 'main.js'),
|
||||
tmpdir.resolve('main.js'),
|
||||
'console.log(JSON.stringify(process.argv));',
|
||||
'utf-8');
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ if (process.versions.icu) {
|
||||
// ICU is unavailable, use characters that can't be decomposed
|
||||
dirName = 'weird \ud83d\udc04 characters \ud83d\udc05';
|
||||
}
|
||||
const dir = path.resolve(tmpdir.path, dirName);
|
||||
const dir = tmpdir.resolve(dirName);
|
||||
|
||||
// Make sure that the tmp directory is clean
|
||||
tmpdir.refresh();
|
||||
|
||||
@@ -5,7 +5,6 @@ if (common.isWindows)
|
||||
|
||||
const assert = require('assert');
|
||||
const child_process = require('child_process');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
assert.strictEqual(process.execPath, fs.realpathSync(process.execPath));
|
||||
@@ -17,7 +16,7 @@ if (process.argv[2] === 'child') {
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
const symlinkedNode = path.join(tmpdir.path, 'symlinked-node');
|
||||
const symlinkedNode = tmpdir.resolve('symlinked-node');
|
||||
fs.symlinkSync(process.execPath, symlinkedNode);
|
||||
|
||||
const proc = child_process.spawnSync(symlinkedNode, [__filename, 'child']);
|
||||
|
||||
@@ -9,14 +9,13 @@ const common = require('../common');
|
||||
const fixtures = require('../common/fixtures');
|
||||
const fs = require('fs');
|
||||
const fork = require('child_process').fork;
|
||||
const path = require('path');
|
||||
const assert = require('assert');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
const warnmod = require.resolve(fixtures.path('warnings.js'));
|
||||
const warnpath = path.join(tmpdir.path, 'warnings.txt');
|
||||
const warnpath = tmpdir.resolve('warnings.txt');
|
||||
|
||||
fork(warnmod, { env: { ...process.env, NODE_REDIRECT_WARNINGS: warnpath } })
|
||||
.on('exit', common.mustCall(() => {
|
||||
|
||||
@@ -9,14 +9,13 @@ const common = require('../common');
|
||||
const fixtures = require('../common/fixtures');
|
||||
const fs = require('fs');
|
||||
const fork = require('child_process').fork;
|
||||
const path = require('path');
|
||||
const assert = require('assert');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
const warnmod = fixtures.path('warnings.js');
|
||||
const warnpath = path.join(tmpdir.path, 'warnings.txt');
|
||||
const warnpath = tmpdir.resolve('warnings.txt');
|
||||
|
||||
fork(warnmod, { execArgv: [`--redirect-warnings=${warnpath}`] })
|
||||
.on('exit', common.mustCall(() => {
|
||||
|
||||
@@ -8,10 +8,10 @@ const path = require('path');
|
||||
|
||||
tmpdir.refresh();
|
||||
|
||||
const fooPath = path.join(tmpdir.path, 'foo.cjs');
|
||||
const fooPath = tmpdir.resolve('foo.cjs');
|
||||
fs.writeFileSync(fooPath, '');
|
||||
|
||||
const dirPath = path.join(tmpdir.path, 'delete_me');
|
||||
const dirPath = tmpdir.resolve('delete_me');
|
||||
fs.mkdirSync(dirPath, {
|
||||
recursive: true
|
||||
});
|
||||
|
||||
@@ -10,7 +10,7 @@ const tmpdir = require('../common/tmpdir');
|
||||
|
||||
// Make a path that is more than 260 chars long.
|
||||
const dirNameLen = Math.max(260 - tmpdir.path.length, 1);
|
||||
const dirName = path.join(tmpdir.path, 'x'.repeat(dirNameLen));
|
||||
const dirName = tmpdir.resolve('x'.repeat(dirNameLen));
|
||||
const fullDirPath = path.resolve(dirName);
|
||||
|
||||
const indexFile = path.join(fullDirPath, 'index.js');
|
||||
|
||||
@@ -20,7 +20,7 @@ const fixtures = require('../common/fixtures');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const dirName = 'module-require-symlink';
|
||||
const fixtureSource = fixtures.path(dirName);
|
||||
const tmpDirTarget = path.join(tmpdir.path, dirName);
|
||||
const tmpDirTarget = tmpdir.resolve(dirName);
|
||||
|
||||
// Copy fixtureSource to linkTarget recursively.
|
||||
tmpdir.refresh();
|
||||
|
||||
@@ -8,7 +8,7 @@ const path = require('path');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
const dirname = path.join(tmpdir.path, '\u4e2d\u6587\u76ee\u5f55');
|
||||
const dirname = tmpdir.resolve('\u4e2d\u6587\u76ee\u5f55');
|
||||
fs.mkdirSync(dirname);
|
||||
fs.writeFileSync(path.join(dirname, 'file.js'), 'module.exports = 42;');
|
||||
fs.writeFileSync(path.join(dirname, 'package.json'),
|
||||
|
||||
@@ -4,7 +4,6 @@ const tmpdir = require('../common/tmpdir');
|
||||
const fixtures = require('../common/fixtures');
|
||||
const { describe, it, test } = require('node:test');
|
||||
const assert = require('node:assert');
|
||||
const path = require('node:path');
|
||||
const fs = require('node:fs/promises');
|
||||
const os = require('node:os');
|
||||
const timers = require('node:timers/promises');
|
||||
@@ -88,7 +87,7 @@ describe('concurrency: true implies Infinity', { concurrency: true }, () => {
|
||||
}
|
||||
|
||||
test('--test multiple files', { skip: os.availableParallelism() < 3 }, async () => {
|
||||
await fs.writeFile(path.resolve(tmpdir.path, 'test-runner-concurrency'), '');
|
||||
await fs.writeFile(tmpdir.resolve('test-runner-concurrency'), '');
|
||||
const { code, stderr } = await common.spawnPromisified(process.execPath, [
|
||||
'--test',
|
||||
fixtures.path('test-runner', 'concurrency', 'a.mjs'),
|
||||
|
||||
@@ -29,8 +29,8 @@ for (const name in ['test', 'test/reporters']) {
|
||||
// Verify that files in node_modules can be resolved.
|
||||
tmpdir.refresh();
|
||||
|
||||
const packageRoot = path.join(tmpdir.path, 'node_modules', 'test');
|
||||
const reportersDir = path.join(tmpdir.path, 'node_modules', 'test', 'reporters');
|
||||
const packageRoot = tmpdir.resolve('node_modules', 'test');
|
||||
const reportersDir = tmpdir.resolve('node_modules', 'test', 'reporters');
|
||||
const indexFile = path.join(packageRoot, 'index.js');
|
||||
const reportersIndexFile = path.join(reportersDir, 'index.js');
|
||||
|
||||
@@ -59,7 +59,7 @@ test(['--input-type=module', '-e', 'console.log((await import("test")).default)'
|
||||
test(['--input-type=module', '-e', 'console.log((await import("test/reporters")).default)'], true);
|
||||
|
||||
{
|
||||
const dummyFile = path.join(tmpdir.path, 'file.js');
|
||||
const dummyFile = tmpdir.resolve('file.js');
|
||||
const require = createRequire(dummyFile);
|
||||
assert.strictEqual(require.resolve('test'), indexFile);
|
||||
assert.strictEqual(require.resolve('test/reporters'), reportersIndexFile);
|
||||
|
||||
@@ -61,7 +61,7 @@ tmpdir.refresh();
|
||||
|
||||
// Outputs coverage when event loop is drained, with no async logic.
|
||||
{
|
||||
const coverageDirectory = path.join(tmpdir.path, 'coverage');
|
||||
const coverageDirectory = tmpdir.resolve('coverage');
|
||||
async function getCoveredFiles() {
|
||||
const coverageFiles = await fs.readdir(coverageDirectory);
|
||||
const files = new Set();
|
||||
|
||||
@@ -6,7 +6,6 @@ const tmpdir = require('../common/tmpdir');
|
||||
const { describe, it } = require('node:test');
|
||||
const { spawnSync } = require('node:child_process');
|
||||
const assert = require('node:assert');
|
||||
const path = require('node:path');
|
||||
const fs = require('node:fs');
|
||||
|
||||
const testFile = fixtures.path('test-runner/reporters.js');
|
||||
@@ -56,7 +55,7 @@ describe('node:test reporters', { concurrency: true }, () => {
|
||||
});
|
||||
|
||||
it('should support a file as a destination', async () => {
|
||||
const file = path.join(tmpdir.path, `${tmpFiles++}.out`);
|
||||
const file = tmpdir.resolve(`${tmpFiles++}.out`);
|
||||
const child = spawnSync(process.execPath,
|
||||
['--test', '--test-reporter', 'dot', '--test-reporter-destination', file, testFile]);
|
||||
assert.strictEqual(child.stderr.toString(), '');
|
||||
@@ -72,8 +71,8 @@ describe('node:test reporters', { concurrency: true }, () => {
|
||||
});
|
||||
|
||||
it('should support multiple reporters', async () => {
|
||||
const file = path.join(tmpdir.path, `${tmpFiles++}.out`);
|
||||
const file2 = path.join(tmpdir.path, `${tmpFiles++}.out`);
|
||||
const file = tmpdir.resolve(`${tmpFiles++}.out`);
|
||||
const file2 = tmpdir.resolve(`${tmpFiles++}.out`);
|
||||
const child = spawnSync(process.execPath,
|
||||
['--test',
|
||||
'--test-reporter', 'dot', '--test-reporter-destination', file,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Flags: --expose-internals
|
||||
import * as common from '../common/index.mjs';
|
||||
import path from 'node:path';
|
||||
import { describe, it } from 'node:test';
|
||||
import { spawn } from 'node:child_process';
|
||||
import { writeFileSync } from 'node:fs';
|
||||
@@ -26,7 +25,7 @@ import('data:text/javascript,');
|
||||
test('test has ran');`,
|
||||
};
|
||||
const fixturePaths = Object.keys(fixtureContent)
|
||||
.reduce((acc, file) => ({ ...acc, [file]: path.join(tmpdir.path, file) }), {});
|
||||
.reduce((acc, file) => ({ ...acc, [file]: tmpdir.resolve(file) }), {});
|
||||
Object.entries(fixtureContent)
|
||||
.forEach(([file, content]) => writeFileSync(fixturePaths[file], content));
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ const tmpdir = require('../common/tmpdir');
|
||||
const { writeFileSync, mkdirSync } = require('fs');
|
||||
const { spawnSync } = require('child_process');
|
||||
const assert = require('assert');
|
||||
const { join } = require('path');
|
||||
|
||||
{
|
||||
tmpdir.refresh();
|
||||
@@ -27,7 +26,7 @@ const { join } = require('path');
|
||||
|
||||
{
|
||||
tmpdir.refresh();
|
||||
const config = join(tmpdir.path, 'non-existent-absolute.json');
|
||||
const config = tmpdir.resolve('non-existent-absolute.json');
|
||||
const child = spawnSync(
|
||||
process.execPath,
|
||||
['--experimental-sea-config', config], {
|
||||
@@ -44,7 +43,7 @@ const { join } = require('path');
|
||||
|
||||
{
|
||||
tmpdir.refresh();
|
||||
const config = join(tmpdir.path, 'invalid.json');
|
||||
const config = tmpdir.resolve('invalid.json');
|
||||
writeFileSync(config, '\n{\n"main"', 'utf8');
|
||||
const child = spawnSync(
|
||||
process.execPath,
|
||||
@@ -63,7 +62,7 @@ const { join } = require('path');
|
||||
|
||||
{
|
||||
tmpdir.refresh();
|
||||
const config = join(tmpdir.path, 'empty.json');
|
||||
const config = tmpdir.resolve('empty.json');
|
||||
writeFileSync(config, '{}', 'utf8');
|
||||
const child = spawnSync(
|
||||
process.execPath,
|
||||
@@ -81,7 +80,7 @@ const { join } = require('path');
|
||||
|
||||
{
|
||||
tmpdir.refresh();
|
||||
const config = join(tmpdir.path, 'no-main.json');
|
||||
const config = tmpdir.resolve('no-main.json');
|
||||
writeFileSync(config, '{"output": "test.blob"}', 'utf8');
|
||||
const child = spawnSync(
|
||||
process.execPath,
|
||||
@@ -99,7 +98,7 @@ const { join } = require('path');
|
||||
|
||||
{
|
||||
tmpdir.refresh();
|
||||
const config = join(tmpdir.path, 'no-output.json');
|
||||
const config = tmpdir.resolve('no-output.json');
|
||||
writeFileSync(config, '{"main": "bundle.js"}', 'utf8');
|
||||
const child = spawnSync(
|
||||
process.execPath,
|
||||
@@ -117,7 +116,7 @@ const { join } = require('path');
|
||||
|
||||
{
|
||||
tmpdir.refresh();
|
||||
const config = join(tmpdir.path, 'invalid-disableExperimentalSEAWarning.json');
|
||||
const config = tmpdir.resolve('invalid-disableExperimentalSEAWarning.json');
|
||||
writeFileSync(config, `
|
||||
{
|
||||
"main": "bundle.js",
|
||||
@@ -141,7 +140,7 @@ const { join } = require('path');
|
||||
|
||||
{
|
||||
tmpdir.refresh();
|
||||
const config = join(tmpdir.path, 'nonexistent-main-relative.json');
|
||||
const config = tmpdir.resolve('nonexistent-main-relative.json');
|
||||
writeFileSync(config, '{"main": "bundle.js", "output": "sea.blob"}', 'utf8');
|
||||
const child = spawnSync(
|
||||
process.execPath,
|
||||
@@ -155,8 +154,8 @@ const { join } = require('path');
|
||||
|
||||
{
|
||||
tmpdir.refresh();
|
||||
const config = join(tmpdir.path, 'nonexistent-main-absolute.json');
|
||||
const main = join(tmpdir.path, 'bundle.js');
|
||||
const config = tmpdir.resolve('nonexistent-main-absolute.json');
|
||||
const main = tmpdir.resolve('bundle.js');
|
||||
const configJson = JSON.stringify({
|
||||
main,
|
||||
output: 'sea.blob'
|
||||
@@ -179,9 +178,9 @@ const { join } = require('path');
|
||||
|
||||
{
|
||||
tmpdir.refresh();
|
||||
const config = join(tmpdir.path, 'output-is-dir-absolute.json');
|
||||
const main = join(tmpdir.path, 'bundle.js');
|
||||
const output = join(tmpdir.path, 'output-dir');
|
||||
const config = tmpdir.resolve('output-is-dir-absolute.json');
|
||||
const main = tmpdir.resolve('bundle.js');
|
||||
const output = tmpdir.resolve('output-dir');
|
||||
mkdirSync(output);
|
||||
writeFileSync(main, 'console.log("hello")', 'utf-8');
|
||||
const configJson = JSON.stringify({
|
||||
@@ -206,9 +205,9 @@ const { join } = require('path');
|
||||
|
||||
{
|
||||
tmpdir.refresh();
|
||||
const config = join(tmpdir.path, 'output-is-dir-relative.json');
|
||||
const main = join(tmpdir.path, 'bundle.js');
|
||||
const output = join(tmpdir.path, 'output-dir');
|
||||
const config = tmpdir.resolve('output-is-dir-relative.json');
|
||||
const main = tmpdir.resolve('bundle.js');
|
||||
const output = tmpdir.resolve('output-dir');
|
||||
mkdirSync(output);
|
||||
writeFileSync(main, 'console.log("hello")', 'utf-8');
|
||||
const configJson = JSON.stringify({
|
||||
|
||||
@@ -6,13 +6,12 @@ const tmpdir = require('../common/tmpdir');
|
||||
const { writeFileSync, existsSync } = require('fs');
|
||||
const { spawnSync } = require('child_process');
|
||||
const assert = require('assert');
|
||||
const { join } = require('path');
|
||||
|
||||
{
|
||||
tmpdir.refresh();
|
||||
const config = join(tmpdir.path, 'absolute.json');
|
||||
const main = join(tmpdir.path, 'bundle.js');
|
||||
const output = join(tmpdir.path, 'output.blob');
|
||||
const config = tmpdir.resolve('absolute.json');
|
||||
const main = tmpdir.resolve('bundle.js');
|
||||
const output = tmpdir.resolve('output.blob');
|
||||
writeFileSync(main, 'console.log("hello")', 'utf-8');
|
||||
const configJson = JSON.stringify({
|
||||
main,
|
||||
@@ -30,9 +29,9 @@ const { join } = require('path');
|
||||
|
||||
{
|
||||
tmpdir.refresh();
|
||||
const config = join(tmpdir.path, 'relative.json');
|
||||
const main = join(tmpdir.path, 'bundle.js');
|
||||
const output = join(tmpdir.path, 'output.blob');
|
||||
const config = tmpdir.resolve('relative.json');
|
||||
const main = tmpdir.resolve('bundle.js');
|
||||
const output = tmpdir.resolve('output.blob');
|
||||
writeFileSync(main, 'console.log("hello")', 'utf-8');
|
||||
const configJson = JSON.stringify({
|
||||
main: 'bundle.js',
|
||||
@@ -51,9 +50,9 @@ const { join } = require('path');
|
||||
|
||||
{
|
||||
tmpdir.refresh();
|
||||
const config = join(tmpdir.path, 'no-disableExperimentalSEAWarning.json');
|
||||
const main = join(tmpdir.path, 'bundle.js');
|
||||
const output = join(tmpdir.path, 'output.blob');
|
||||
const config = tmpdir.resolve('no-disableExperimentalSEAWarning.json');
|
||||
const main = tmpdir.resolve('bundle.js');
|
||||
const output = tmpdir.resolve('output.blob');
|
||||
writeFileSync(main, 'console.log("hello")', 'utf-8');
|
||||
const configJson = JSON.stringify({
|
||||
main: 'bundle.js',
|
||||
@@ -72,9 +71,9 @@ const { join } = require('path');
|
||||
|
||||
{
|
||||
tmpdir.refresh();
|
||||
const config = join(tmpdir.path, 'true-disableExperimentalSEAWarning.json');
|
||||
const main = join(tmpdir.path, 'bundle.js');
|
||||
const output = join(tmpdir.path, 'output.blob');
|
||||
const config = tmpdir.resolve('true-disableExperimentalSEAWarning.json');
|
||||
const main = tmpdir.resolve('bundle.js');
|
||||
const output = tmpdir.resolve('output.blob');
|
||||
writeFileSync(main, 'console.log("hello")', 'utf-8');
|
||||
const configJson = JSON.stringify({
|
||||
main: 'bundle.js',
|
||||
@@ -94,9 +93,9 @@ const { join } = require('path');
|
||||
|
||||
{
|
||||
tmpdir.refresh();
|
||||
const config = join(tmpdir.path, 'false-disableExperimentalSEAWarning.json');
|
||||
const main = join(tmpdir.path, 'bundle.js');
|
||||
const output = join(tmpdir.path, 'output.blob');
|
||||
const config = tmpdir.resolve('false-disableExperimentalSEAWarning.json');
|
||||
const main = tmpdir.resolve('bundle.js');
|
||||
const output = tmpdir.resolve('output.blob');
|
||||
writeFileSync(main, 'console.log("hello")', 'utf-8');
|
||||
const configJson = JSON.stringify({
|
||||
main: 'bundle.js',
|
||||
|
||||
@@ -16,7 +16,7 @@ tmpdir.refresh();
|
||||
let dirc = 0;
|
||||
function nextdir() {
|
||||
return process.env.NODE_V8_COVERAGE ||
|
||||
path.join(tmpdir.path, `source_map_${++dirc}`);
|
||||
tmpdir.resolve(`source_map_${++dirc}`);
|
||||
}
|
||||
|
||||
// Outputs source maps when event loop is drained, with no async logic.
|
||||
|
||||
@@ -3,12 +3,11 @@ const common = require('../common');
|
||||
const fixtures = require('../common/fixtures');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const assert = require('assert');
|
||||
const { join } = require('path');
|
||||
const childProcess = require('child_process');
|
||||
const fs = require('fs');
|
||||
|
||||
const stdoutScript = fixtures.path('echo-close-check.js');
|
||||
const tmpFile = join(tmpdir.path, 'stdin.txt');
|
||||
const tmpFile = tmpdir.resolve('stdin.txt');
|
||||
|
||||
const cmd = `"${process.argv[0]}" "${stdoutScript}" < "${tmpFile}"`;
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ require('../common');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const join = require('path').join;
|
||||
const { spawnSync } = require('child_process');
|
||||
|
||||
// Test that invoking node with require, and piping stderr to file,
|
||||
@@ -11,8 +10,8 @@ const { spawnSync } = require('child_process');
|
||||
// see: https://github.com/nodejs/node/issues/11257
|
||||
|
||||
tmpdir.refresh();
|
||||
const fakeModulePath = join(tmpdir.path, 'batman.js');
|
||||
const stderrOutputPath = join(tmpdir.path, 'stderr-output.txt');
|
||||
const fakeModulePath = tmpdir.resolve('batman.js');
|
||||
const stderrOutputPath = tmpdir.resolve('stderr-output.txt');
|
||||
// We need to redirect stderr to a file to produce #11257
|
||||
const stream = fs.createWriteStream(stderrOutputPath);
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
const childProcess = require('child_process');
|
||||
const fs = require('fs');
|
||||
const fixtures = require('../common/fixtures');
|
||||
@@ -9,7 +8,7 @@ const tmpdir = require('../common/tmpdir');
|
||||
|
||||
const scriptString = fixtures.path('print-chars.js');
|
||||
const scriptBuffer = fixtures.path('print-chars-from-buffer.js');
|
||||
const tmpFile = path.join(tmpdir.path, 'stdout.txt');
|
||||
const tmpFile = tmpdir.resolve('stdout.txt');
|
||||
|
||||
tmpdir.refresh();
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ const fixtures = require('../common/fixtures');
|
||||
// Test --tls-keylog CLI flag.
|
||||
|
||||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const { fork } = require('child_process');
|
||||
|
||||
@@ -15,7 +14,7 @@ if (process.argv[2] === 'test')
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
const file = path.resolve(tmpdir.path, 'keylog.log');
|
||||
const file = tmpdir.resolve('keylog.log');
|
||||
|
||||
const child = fork(__filename, ['test'], {
|
||||
execArgv: ['--tls-keylog=' + file]
|
||||
|
||||
@@ -18,7 +18,7 @@ function nextdir() {
|
||||
|
||||
// Outputs coverage when event loop is drained, with no async logic.
|
||||
{
|
||||
const coverageDirectory = path.join(tmpdir.path, nextdir());
|
||||
const coverageDirectory = tmpdir.resolve(nextdir());
|
||||
const output = spawnSync(process.execPath, [
|
||||
require.resolve('../fixtures/v8-coverage/basic'),
|
||||
], { env: { ...process.env, NODE_V8_COVERAGE: coverageDirectory } });
|
||||
@@ -37,7 +37,7 @@ function nextdir() {
|
||||
|
||||
// Outputs coverage when error is thrown in first tick.
|
||||
{
|
||||
const coverageDirectory = path.join(tmpdir.path, nextdir());
|
||||
const coverageDirectory = tmpdir.resolve(nextdir());
|
||||
const output = spawnSync(process.execPath, [
|
||||
require.resolve('../fixtures/v8-coverage/throw'),
|
||||
], { env: { ...process.env, NODE_V8_COVERAGE: coverageDirectory } });
|
||||
@@ -55,7 +55,7 @@ function nextdir() {
|
||||
|
||||
// Outputs coverage when process.exit(1) exits process.
|
||||
{
|
||||
const coverageDirectory = path.join(tmpdir.path, nextdir());
|
||||
const coverageDirectory = tmpdir.resolve(nextdir());
|
||||
const output = spawnSync(process.execPath, [
|
||||
require.resolve('../fixtures/v8-coverage/exit-1'),
|
||||
], { env: { ...process.env, NODE_V8_COVERAGE: coverageDirectory } });
|
||||
@@ -74,7 +74,7 @@ function nextdir() {
|
||||
|
||||
// Outputs coverage when process.kill(process.pid, "SIGINT"); exits process.
|
||||
{
|
||||
const coverageDirectory = path.join(tmpdir.path, nextdir());
|
||||
const coverageDirectory = tmpdir.resolve(nextdir());
|
||||
const output = spawnSync(process.execPath, [
|
||||
require.resolve('../fixtures/v8-coverage/sigint'),
|
||||
], { env: { ...process.env, NODE_V8_COVERAGE: coverageDirectory } });
|
||||
@@ -95,7 +95,7 @@ function nextdir() {
|
||||
|
||||
// Outputs coverage from subprocess.
|
||||
{
|
||||
const coverageDirectory = path.join(tmpdir.path, nextdir());
|
||||
const coverageDirectory = tmpdir.resolve(nextdir());
|
||||
const output = spawnSync(process.execPath, [
|
||||
require.resolve('../fixtures/v8-coverage/spawn-subprocess'),
|
||||
], { env: { ...process.env, NODE_V8_COVERAGE: coverageDirectory } });
|
||||
@@ -115,7 +115,7 @@ function nextdir() {
|
||||
|
||||
// Outputs coverage from worker.
|
||||
{
|
||||
const coverageDirectory = path.join(tmpdir.path, nextdir());
|
||||
const coverageDirectory = tmpdir.resolve(nextdir());
|
||||
const output = spawnSync(process.execPath, [
|
||||
require.resolve('../fixtures/v8-coverage/worker'),
|
||||
], { env: { ...process.env, NODE_V8_COVERAGE: coverageDirectory } });
|
||||
@@ -135,7 +135,7 @@ function nextdir() {
|
||||
|
||||
// Does not output coverage if NODE_V8_COVERAGE is empty.
|
||||
{
|
||||
const coverageDirectory = path.join(tmpdir.path, nextdir());
|
||||
const coverageDirectory = tmpdir.resolve(nextdir());
|
||||
const output = spawnSync(process.execPath, [
|
||||
require.resolve('../fixtures/v8-coverage/spawn-subprocess-no-cov'),
|
||||
], { env: { ...process.env, NODE_V8_COVERAGE: coverageDirectory } });
|
||||
@@ -151,7 +151,7 @@ function nextdir() {
|
||||
|
||||
// Disables async hooks before writing coverage.
|
||||
{
|
||||
const coverageDirectory = path.join(tmpdir.path, nextdir());
|
||||
const coverageDirectory = tmpdir.resolve(nextdir());
|
||||
const output = spawnSync(process.execPath, [
|
||||
require.resolve('../fixtures/v8-coverage/async-hooks'),
|
||||
], { env: { ...process.env, NODE_V8_COVERAGE: coverageDirectory } });
|
||||
@@ -170,7 +170,7 @@ function nextdir() {
|
||||
// Outputs coverage when the coverage directory is not absolute.
|
||||
{
|
||||
const coverageDirectory = nextdir();
|
||||
const absoluteCoverageDirectory = path.join(tmpdir.path, coverageDirectory);
|
||||
const absoluteCoverageDirectory = tmpdir.resolve(coverageDirectory);
|
||||
const output = spawnSync(process.execPath, [
|
||||
require.resolve('../fixtures/v8-coverage/basic'),
|
||||
], {
|
||||
|
||||
@@ -7,7 +7,6 @@ const fixtures = require('../common/fixtures');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { spawnSync } = require('child_process');
|
||||
|
||||
tmpdir.refresh();
|
||||
@@ -32,7 +31,7 @@ const intervals = 40;
|
||||
|
||||
let coverages = [];
|
||||
for (const coverageFile of coverageFiles) {
|
||||
const coverage = require(path.join(tmpdir.path, coverageFile));
|
||||
const coverage = require(tmpdir.resolve(coverageFile));
|
||||
for (const result of coverage.result) {
|
||||
if (result.url.includes('/interval')) {
|
||||
coverages.push({
|
||||
|
||||
@@ -9,9 +9,9 @@ const tmpdir = require('../common/tmpdir');
|
||||
const { deepStrictEqual, ok, strictEqual, throws } = require('assert');
|
||||
const { join } = require('path');
|
||||
|
||||
const directory = join(tmpdir.path, 'directory');
|
||||
const doesNotExist = join(tmpdir.path, 'does-not-exist');
|
||||
const file = join(tmpdir.path, 'file.js');
|
||||
const directory = tmpdir.resolve('directory');
|
||||
const doesNotExist = tmpdir.resolve('does-not-exist');
|
||||
const file = tmpdir.resolve('file.js');
|
||||
|
||||
tmpdir.refresh();
|
||||
fs.writeFileSync(file, "module.exports = { a: 'b' }");
|
||||
|
||||
@@ -44,7 +44,7 @@ describe('watch mode file watcher', () => {
|
||||
}
|
||||
|
||||
it('should watch changed files', async () => {
|
||||
const file = path.join(tmpdir.path, 'file1');
|
||||
const file = tmpdir.resolve('file1');
|
||||
writeFileSync(file, 'written');
|
||||
watcher.filterFile(file);
|
||||
await writeAndWaitForChanges(watcher, file);
|
||||
@@ -52,7 +52,7 @@ describe('watch mode file watcher', () => {
|
||||
});
|
||||
|
||||
it('should debounce changes', async () => {
|
||||
const file = path.join(tmpdir.path, 'file2');
|
||||
const file = tmpdir.resolve('file2');
|
||||
writeFileSync(file, 'written');
|
||||
watcher.filterFile(file);
|
||||
await writeAndWaitForChanges(watcher, file);
|
||||
@@ -74,13 +74,13 @@ describe('watch mode file watcher', () => {
|
||||
{ skip: !supportsRecursiveWatching }, async () => {
|
||||
watcher.on('changed', common.mustNotCall());
|
||||
watcher.watchPath(tmpdir.path);
|
||||
writeFileSync(path.join(tmpdir.path, 'file3'), '1');
|
||||
writeFileSync(tmpdir.resolve('file3'), '1');
|
||||
// Wait for this long to make sure changes are not triggered
|
||||
await setTimeout(1000);
|
||||
});
|
||||
|
||||
it('should allow clearing filters', async () => {
|
||||
const file = path.join(tmpdir.path, 'file4');
|
||||
const file = tmpdir.resolve('file4');
|
||||
writeFileSync(file, 'written');
|
||||
watcher.filterFile(file);
|
||||
await writeAndWaitForChanges(watcher, file);
|
||||
@@ -100,7 +100,7 @@ describe('watch mode file watcher', () => {
|
||||
watcher = new FilesWatcher({ debounce: 100, mode: 'all' });
|
||||
watcher.on('changed', () => changesCount++);
|
||||
|
||||
const file = path.join(tmpdir.path, 'file5');
|
||||
const file = tmpdir.resolve('file5');
|
||||
watcher.watchPath(tmpdir.path);
|
||||
|
||||
const changed = once(watcher, 'changed');
|
||||
@@ -124,14 +124,14 @@ describe('watch mode file watcher', () => {
|
||||
assert.deepStrictEqual(watcher.watchedPaths, []);
|
||||
watcher.watchPath(tmpdir.path);
|
||||
assert.deepStrictEqual(watcher.watchedPaths, [tmpdir.path]);
|
||||
watcher.watchPath(path.join(tmpdir.path, 'subdirectory'));
|
||||
watcher.watchPath(tmpdir.resolve('subdirectory'));
|
||||
assert.deepStrictEqual(watcher.watchedPaths, [tmpdir.path]);
|
||||
});
|
||||
|
||||
it('should remove existing watcher if adding a parent directory watcher',
|
||||
{ skip: !supportsRecursiveWatching }, () => {
|
||||
assert.deepStrictEqual(watcher.watchedPaths, []);
|
||||
const subdirectory = path.join(tmpdir.path, 'subdirectory');
|
||||
const subdirectory = tmpdir.resolve('subdirectory');
|
||||
mkdirSync(subdirectory);
|
||||
watcher.watchPath(subdirectory);
|
||||
assert.deepStrictEqual(watcher.watchedPaths, [subdirectory]);
|
||||
@@ -153,7 +153,7 @@ describe('watch mode file watcher', () => {
|
||||
const child = spawn(process.execPath, [file], { stdio: ['pipe', 'pipe', 'pipe', 'ipc'], encoding: 'utf8' });
|
||||
watcher.watchChildProcessModules(child);
|
||||
await once(child, 'exit');
|
||||
let expected = [file, path.join(tmpdir.path, 'file')];
|
||||
let expected = [file, tmpdir.resolve('file')];
|
||||
if (supportsRecursiveWatching) {
|
||||
expected = expected.map((file) => path.dirname(file));
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
const { Worker } = require('worker_threads');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
const missing = path.join(tmpdir.path, 'does-not-exist.js');
|
||||
const missing = tmpdir.resolve('does-not-exist.js');
|
||||
|
||||
const worker = new Worker(missing);
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const zlib = require('zlib');
|
||||
const path = require('path');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
@@ -17,7 +16,7 @@ const fs = require('fs');
|
||||
|
||||
const fixture = fixtures.path('person.jpg.br');
|
||||
const unzippedFixture = fixtures.path('person.jpg');
|
||||
const outputFile = path.resolve(tmpdir.path, 'person.jpg');
|
||||
const outputFile = tmpdir.resolve('person.jpg');
|
||||
const expect = fs.readFileSync(unzippedFixture);
|
||||
const inp = fs.createReadStream(fixture);
|
||||
const out = fs.createWriteStream(outputFile);
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const zlib = require('zlib');
|
||||
const path = require('path');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
@@ -38,7 +37,7 @@ const fs = require('fs');
|
||||
|
||||
const fixture = fixtures.path('person.jpg.gz');
|
||||
const unzippedFixture = fixtures.path('person.jpg');
|
||||
const outputFile = path.resolve(tmpdir.path, 'person.jpg');
|
||||
const outputFile = tmpdir.resolve('person.jpg');
|
||||
const expect = fs.readFileSync(unzippedFixture);
|
||||
const inp = fs.createReadStream(fixture);
|
||||
const out = fs.createWriteStream(outputFile);
|
||||
|
||||
Reference in New Issue
Block a user