mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
test: move tmpdir to submodule of common
Move tmpdir functionality to its own module (common/tmpdir). Backport-PR-URL: https://github.com/nodejs/node/pull/19488 PR-URL: https://github.com/nodejs/node/pull/17856 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This commit is contained in:
parent
965b56a34e
commit
a1b0d5da07
|
|
@ -2,22 +2,15 @@
|
|||
|
||||
const assert = require('assert');
|
||||
const http = require('http');
|
||||
const fs = require('fs');
|
||||
const { fork } = require('child_process');
|
||||
const common = require('../common.js');
|
||||
const { PIPE, tmpDir } = require('../../test/common');
|
||||
const { PIPE } = require('../../test/common');
|
||||
const tmpdir = require('../../test/common/tmpdir');
|
||||
process.env.PIPE_NAME = PIPE;
|
||||
|
||||
try {
|
||||
fs.accessSync(tmpDir, fs.F_OK);
|
||||
} catch (e) {
|
||||
fs.mkdirSync(tmpDir);
|
||||
}
|
||||
tmpdir.refresh();
|
||||
|
||||
var server;
|
||||
try {
|
||||
fs.unlinkSync(process.env.PIPE_NAME);
|
||||
} catch (e) { /* ignore */ }
|
||||
|
||||
server = http.createServer(function(req, res) {
|
||||
const headers = {
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ const fs = require('fs');
|
|||
const path = require('path');
|
||||
const common = require('../common.js');
|
||||
|
||||
const { refreshTmpDir, tmpDir } = require('../../test/common');
|
||||
const benchmarkDirectory = path.join(tmpDir, 'nodejs-benchmark-module');
|
||||
const tmpdir = require('../../test/common/tmpdir');
|
||||
const benchmarkDirectory = path.join(tmpdir.path, 'nodejs-benchmark-module');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
thousands: [50],
|
||||
|
|
@ -15,7 +15,7 @@ const bench = common.createBenchmark(main, {
|
|||
function main(conf) {
|
||||
const n = +conf.thousands * 1e3;
|
||||
|
||||
refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
try { fs.mkdirSync(benchmarkDirectory); } catch (e) {}
|
||||
|
||||
for (var i = 0; i <= n; i++) {
|
||||
|
|
@ -35,7 +35,7 @@ function main(conf) {
|
|||
else
|
||||
measureDir(n, conf.useCache === 'true');
|
||||
|
||||
refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
}
|
||||
|
||||
function measureFull(n, useCache) {
|
||||
|
|
|
|||
|
|
@ -7,12 +7,13 @@ const fs = require('fs');
|
|||
const path = require('path');
|
||||
const assert = require('assert');
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
// make a path that is more than 260 chars long.
|
||||
// Any given folder cannot have a name longer than 260 characters,
|
||||
// so create 10 nested folders each with 30 character long names.
|
||||
let addonDestinationDir = path.resolve(common.tmpDir);
|
||||
let addonDestinationDir = path.resolve(tmpdir.path);
|
||||
|
||||
for (let i = 0; i < 10; i++) {
|
||||
addonDestinationDir = path.join(addonDestinationDir, 'x'.repeat(30));
|
||||
|
|
|
|||
|
|
@ -12,10 +12,11 @@ const assert = require('assert');
|
|||
// This test should pass in Node.js v4 and v5. This test will pass in Node.js
|
||||
// with https://github.com/nodejs/node/pull/5950 reverted.
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
const addonPath = path.join(__dirname, 'build', common.buildType);
|
||||
const addonLink = path.join(common.tmpDir, 'addon');
|
||||
const addonLink = path.join(tmpdir.path, 'addon');
|
||||
|
||||
try {
|
||||
fs.symlinkSync(addonPath, addonLink);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ const verifyGraph = require('./verify-graph');
|
|||
|
||||
const net = require('net');
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
const hooks = initHooks();
|
||||
hooks.enable();
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ const { checkInvocations } = require('./hook-checks');
|
|||
|
||||
const net = require('net');
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
const hooks = initHooks();
|
||||
hooks.enable();
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ This directory contains modules used to test the Node.js implementation.
|
|||
* [DNS module](#dns-module)
|
||||
* [Duplex pair helper](#duplex-pair-helper)
|
||||
* [Fixtures module](#fixtures-module)
|
||||
* [tmpdir module](#tmpdir-module)
|
||||
* [WPT module](#wpt-module)
|
||||
|
||||
## Benchmark Module
|
||||
|
|
@ -312,11 +313,6 @@ A port number for tests to use if one is needed.
|
|||
|
||||
Logs '1..0 # Skipped: ' + `msg`
|
||||
|
||||
### refreshTmpDir()
|
||||
* return [<String>]
|
||||
|
||||
Deletes the testing 'tmp' directory and recreates it.
|
||||
|
||||
### restoreStderr()
|
||||
|
||||
Restore the original `process.stderr.write`. Used to restore `stderr` to its
|
||||
|
|
@ -369,11 +365,6 @@ Platform normalizes the `pwd` command.
|
|||
|
||||
Synchronous version of `spawnPwd`.
|
||||
|
||||
### tmpDir
|
||||
* [<String>]
|
||||
|
||||
The realpath of the 'tmp' directory.
|
||||
|
||||
## Countdown Module
|
||||
|
||||
The `Countdown` module provides a simple countdown mechanism for tests that
|
||||
|
|
@ -492,6 +483,19 @@ Returns the result of
|
|||
Returns the result of
|
||||
`fs.readFileSync(path.join(fixtures.fixturesDir, 'keys', arg), 'enc')`.
|
||||
|
||||
## tmpdir Module
|
||||
|
||||
The `tmpdir` module supports the use of a temporary directory for testing.
|
||||
|
||||
### path
|
||||
* [<String>]
|
||||
|
||||
The realpath of the testing temporary directory.
|
||||
|
||||
### refresh()
|
||||
|
||||
Deletes and recreates the testing temporary directory.
|
||||
|
||||
## WPT Module
|
||||
|
||||
The wpt.js module is a port of parts of
|
||||
|
|
|
|||
|
|
@ -30,15 +30,10 @@ const stream = require('stream');
|
|||
const util = require('util');
|
||||
const Timer = process.binding('timer_wrap').Timer;
|
||||
const { fixturesDir } = require('./fixtures');
|
||||
|
||||
const testRoot = process.env.NODE_TEST_DIR ?
|
||||
fs.realpathSync(process.env.NODE_TEST_DIR) : path.resolve(__dirname, '..');
|
||||
const tmpdir = require('./tmpdir');
|
||||
|
||||
const noop = () => {};
|
||||
|
||||
// Using a `.` prefixed name, which is the convention for "hidden" on POSIX,
|
||||
// gets tools to ignore it by default or by simple rules, especially eslint.
|
||||
let tmpDirName = '.tmp';
|
||||
// PORT should match the definition in test/testpy/__init__.py.
|
||||
exports.PORT = +process.env.NODE_COMMON_PORT || 12346;
|
||||
exports.isWindows = process.platform === 'win32';
|
||||
|
|
@ -121,63 +116,6 @@ if (process.env.NODE_TEST_WITH_ASYNC_HOOKS) {
|
|||
}).enable();
|
||||
}
|
||||
|
||||
function rimrafSync(p) {
|
||||
let st;
|
||||
try {
|
||||
st = fs.lstatSync(p);
|
||||
} catch (e) {
|
||||
if (e.code === 'ENOENT')
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (st && st.isDirectory())
|
||||
rmdirSync(p, null);
|
||||
else
|
||||
fs.unlinkSync(p);
|
||||
} catch (e) {
|
||||
if (e.code === 'ENOENT')
|
||||
return;
|
||||
if (e.code === 'EPERM')
|
||||
return rmdirSync(p, e);
|
||||
if (e.code !== 'EISDIR')
|
||||
throw e;
|
||||
rmdirSync(p, e);
|
||||
}
|
||||
}
|
||||
|
||||
function rmdirSync(p, originalEr) {
|
||||
try {
|
||||
fs.rmdirSync(p);
|
||||
} catch (e) {
|
||||
if (e.code === 'ENOTDIR')
|
||||
throw originalEr;
|
||||
if (e.code === 'ENOTEMPTY' || e.code === 'EEXIST' || e.code === 'EPERM') {
|
||||
const enc = exports.isLinux ? 'buffer' : 'utf8';
|
||||
fs.readdirSync(p, enc).forEach((f) => {
|
||||
if (f instanceof Buffer) {
|
||||
const buf = Buffer.concat([Buffer.from(p), Buffer.from(path.sep), f]);
|
||||
rimrafSync(buf);
|
||||
} else {
|
||||
rimrafSync(path.join(p, f));
|
||||
}
|
||||
});
|
||||
fs.rmdirSync(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.refreshTmpDir = function() {
|
||||
rimrafSync(exports.tmpDir);
|
||||
fs.mkdirSync(exports.tmpDir);
|
||||
};
|
||||
|
||||
if (process.env.TEST_THREAD_ID) {
|
||||
exports.PORT += process.env.TEST_THREAD_ID * 100;
|
||||
tmpDirName += `.${process.env.TEST_THREAD_ID}`;
|
||||
}
|
||||
exports.tmpDir = path.join(testRoot, tmpDirName);
|
||||
|
||||
let opensslCli = null;
|
||||
let inFreeBSDJail = null;
|
||||
let localhostIPv4 = null;
|
||||
|
|
@ -271,7 +209,7 @@ Object.defineProperty(exports, 'hasFipsCrypto', {
|
|||
});
|
||||
|
||||
{
|
||||
const localRelative = path.relative(process.cwd(), `${exports.tmpDir}/`);
|
||||
const localRelative = path.relative(process.cwd(), `${tmpdir.path}/`);
|
||||
const pipePrefix = exports.isWindows ? '\\\\.\\pipe\\' : localRelative;
|
||||
const pipeName = `node-test.${process.pid}.sock`;
|
||||
exports.PIPE = path.join(pipePrefix, pipeName);
|
||||
|
|
|
|||
67
test/common/tmpdir.js
Normal file
67
test/common/tmpdir.js
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
/* eslint-disable required-modules */
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
function rimrafSync(p) {
|
||||
let st;
|
||||
try {
|
||||
st = fs.lstatSync(p);
|
||||
} catch (e) {
|
||||
if (e.code === 'ENOENT')
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (st && st.isDirectory())
|
||||
rmdirSync(p, null);
|
||||
else
|
||||
fs.unlinkSync(p);
|
||||
} catch (e) {
|
||||
if (e.code === 'ENOENT')
|
||||
return;
|
||||
if (e.code === 'EPERM')
|
||||
return rmdirSync(p, e);
|
||||
if (e.code !== 'EISDIR')
|
||||
throw e;
|
||||
rmdirSync(p, e);
|
||||
}
|
||||
}
|
||||
|
||||
function rmdirSync(p, originalEr) {
|
||||
try {
|
||||
fs.rmdirSync(p);
|
||||
} catch (e) {
|
||||
if (e.code === 'ENOTDIR')
|
||||
throw originalEr;
|
||||
if (e.code === 'ENOTEMPTY' || e.code === 'EEXIST' || e.code === 'EPERM') {
|
||||
const enc = process.platform === 'linux' ? 'buffer' : 'utf8';
|
||||
fs.readdirSync(p, enc).forEach((f) => {
|
||||
if (f instanceof Buffer) {
|
||||
const buf = Buffer.concat([Buffer.from(p), Buffer.from(path.sep), f]);
|
||||
rimrafSync(buf);
|
||||
} else {
|
||||
rimrafSync(path.join(p, f));
|
||||
}
|
||||
});
|
||||
fs.rmdirSync(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const testRoot = process.env.NODE_TEST_DIR ?
|
||||
fs.realpathSync(process.env.NODE_TEST_DIR) : path.resolve(__dirname, '..');
|
||||
|
||||
// Using a `.` prefixed name, which is the convention for "hidden" on POSIX,
|
||||
// gets tools to ignore it by default or by simple rules, especially eslint.
|
||||
let tmpdirName = '.tmp';
|
||||
if (process.env.TEST_THREAD_ID) {
|
||||
tmpdirName += `.${process.env.TEST_THREAD_ID}`;
|
||||
}
|
||||
exports.path = path.join(testRoot, tmpdirName);
|
||||
|
||||
exports.refresh = () => {
|
||||
rimrafSync(exports.path);
|
||||
fs.mkdirSync(exports.path);
|
||||
};
|
||||
|
|
@ -7,8 +7,9 @@ const assert = require('assert');
|
|||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpDir = common.tmpDir;
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
const tmpDir = tmpdir.path;
|
||||
|
||||
const entry = path.join(tmpDir, 'entry.js');
|
||||
const real = path.join(tmpDir, 'real.js');
|
||||
|
|
|
|||
|
|
@ -6,8 +6,9 @@ const assert = require('assert');
|
|||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpDir = common.tmpDir;
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
const tmpDir = tmpdir.path;
|
||||
|
||||
const entry = path.join(tmpDir, 'entry.mjs');
|
||||
const real = path.join(tmpDir, 'index.mjs');
|
||||
|
|
|
|||
|
|
@ -17,8 +17,9 @@ const fs = require('fs');
|
|||
if (process.argv[2] === 'child') {
|
||||
// Do nothing.
|
||||
} else {
|
||||
common.refreshTmpDir();
|
||||
const dir = fs.mkdtempSync(`${common.tmpDir}/`);
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
const dir = fs.mkdtempSync(`${tmpdir.path}/`);
|
||||
process.chdir(dir);
|
||||
fs.rmdirSync(dir);
|
||||
assert.throws(process.cwd,
|
||||
|
|
|
|||
|
|
@ -4,9 +4,10 @@ const common = require('../common');
|
|||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const file = path.join(common.tmpDir, 'test-extensions.foo.bar');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const file = path.join(tmpdir.path, 'test-extensions.foo.bar');
|
||||
|
||||
common.refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
fs.writeFileSync(file, '', 'utf8');
|
||||
require.extensions['.foo.bar'] = (module, path) => {};
|
||||
delete require.extensions['.foo.bar'];
|
||||
|
|
@ -14,4 +15,4 @@ require.extensions['.bar'] = common.mustCall((module, path) => {
|
|||
assert.strictEqual(module.id, file);
|
||||
assert.strictEqual(path, file);
|
||||
});
|
||||
require(path.join(common.tmpDir, 'test-extensions'));
|
||||
require(path.join(tmpdir.path, 'test-extensions'));
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
require('../common');
|
||||
const runBenchmark = require('../common/benchmark');
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
runBenchmark('fs', [
|
||||
'n=1',
|
||||
|
|
@ -16,4 +17,4 @@ runBenchmark('fs', [
|
|||
'statSyncType=fstatSync',
|
||||
'encodingType=buf',
|
||||
'filesize=1024'
|
||||
], { NODE_TMPDIR: common.tmpDir, NODEJS_BENCHMARK_ZERO_ALLOWED: 1 });
|
||||
], { NODE_TMPDIR: tmpdir.path, NODEJS_BENCHMARK_ZERO_ALLOWED: 1 });
|
||||
|
|
|
|||
|
|
@ -24,9 +24,10 @@ const common = require('../common');
|
|||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const msg = { test: 'this' };
|
||||
const nodePath = process.execPath;
|
||||
const copyPath = path.join(common.tmpDir, 'node-copy.exe');
|
||||
const copyPath = path.join(tmpdir.path, 'node-copy.exe');
|
||||
|
||||
if (process.env.FORK) {
|
||||
assert(process.send);
|
||||
|
|
@ -34,7 +35,7 @@ if (process.env.FORK) {
|
|||
process.send(msg);
|
||||
process.exit();
|
||||
} else {
|
||||
common.refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
try {
|
||||
fs.unlinkSync(copyPath);
|
||||
} catch (e) {
|
||||
|
|
|
|||
|
|
@ -8,8 +8,9 @@ if (process.config.variables.node_without_node_options)
|
|||
const assert = require('assert');
|
||||
const exec = require('child_process').execFile;
|
||||
|
||||
common.refreshTmpDir();
|
||||
process.chdir(common.tmpDir);
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
process.chdir(tmpdir.path);
|
||||
|
||||
disallow('--version');
|
||||
disallow('-v');
|
||||
|
|
|
|||
|
|
@ -8,8 +8,9 @@ if (process.config.variables.node_without_node_options)
|
|||
const assert = require('assert');
|
||||
const exec = require('child_process').execFile;
|
||||
|
||||
common.refreshTmpDir();
|
||||
process.chdir(common.tmpDir);
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
process.chdir(tmpdir.path);
|
||||
|
||||
expect(`-r ${require.resolve('../fixtures/printA.js')}`, 'A\nB\n');
|
||||
expect('--no-deprecation', 'B\n');
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ const net = require('net');
|
|||
|
||||
if (cluster.isMaster && process.argv.length !== 3) {
|
||||
// cluster.isMaster
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
const PIPE_NAME = common.PIPE;
|
||||
const worker = cluster.fork({ PIPE_NAME });
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ const cluster = require('cluster');
|
|||
const http = require('http');
|
||||
|
||||
if (cluster.isMaster) {
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
const worker = cluster.fork();
|
||||
worker.on('message', common.mustCall((msg) => {
|
||||
assert.strictEqual(msg, 'DONE');
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ const net = require('net');
|
|||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
if (common.isWindows)
|
||||
common.skip('On Windows named pipes live in their own ' +
|
||||
'filesystem and don\'t have a ~100 byte limit');
|
||||
|
|
@ -20,8 +22,8 @@ assert.strictEqual(path.resolve(socketDir, socketName).length > 100, true,
|
|||
|
||||
if (cluster.isMaster) {
|
||||
// ensure that the worker exits peacefully
|
||||
common.refreshTmpDir();
|
||||
process.chdir(common.tmpDir);
|
||||
tmpdir.refresh();
|
||||
process.chdir(tmpdir.path);
|
||||
fs.mkdirSync(socketDir);
|
||||
cluster.fork().on('exit', common.mustCall(function(statusCode) {
|
||||
assert.strictEqual(statusCode, 0);
|
||||
|
|
|
|||
|
|
@ -255,11 +255,12 @@ const modSize = 1024;
|
|||
padding: crypto.constants.RSA_PKCS1_PSS_PADDING
|
||||
});
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
const sigfile = path.join(common.tmpDir, 's5.sig');
|
||||
const sigfile = path.join(tmpdir.path, 's5.sig');
|
||||
fs.writeFileSync(sigfile, s5);
|
||||
const msgfile = path.join(common.tmpDir, 's5.msg');
|
||||
const msgfile = path.join(tmpdir.path, 's5.msg');
|
||||
fs.writeFileSync(msgfile, msg);
|
||||
|
||||
const cmd =
|
||||
|
|
|
|||
|
|
@ -8,10 +8,11 @@ const assert = require('assert');
|
|||
const fs = require('fs');
|
||||
const spawn = require('child_process').spawn;
|
||||
const fixtures = require('../common/fixtures');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
const dirname = `${common.tmpDir}/cwd-does-not-exist-${process.pid}`;
|
||||
const dirname = `${tmpdir.path}/cwd-does-not-exist-${process.pid}`;
|
||||
const abspathFile = fixtures.path('a.js');
|
||||
common.refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
fs.mkdirSync(dirname);
|
||||
process.chdir(dirname);
|
||||
fs.rmdirSync(dirname);
|
||||
|
|
|
|||
|
|
@ -8,8 +8,10 @@ const assert = require('assert');
|
|||
const fs = require('fs');
|
||||
const spawn = require('child_process').spawn;
|
||||
|
||||
const dirname = `${common.tmpDir}/cwd-does-not-exist-${process.pid}`;
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
const dirname = `${tmpdir.path}/cwd-does-not-exist-${process.pid}`;
|
||||
tmpdir.refresh();
|
||||
fs.mkdirSync(dirname);
|
||||
process.chdir(dirname);
|
||||
fs.rmdirSync(dirname);
|
||||
|
|
|
|||
|
|
@ -8,8 +8,10 @@ const assert = require('assert');
|
|||
const fs = require('fs');
|
||||
const spawn = require('child_process').spawn;
|
||||
|
||||
const dirname = `${common.tmpDir}/cwd-does-not-exist-${process.pid}`;
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
const dirname = `${tmpdir.path}/cwd-does-not-exist-${process.pid}`;
|
||||
tmpdir.refresh();
|
||||
fs.mkdirSync(dirname);
|
||||
process.chdir(dirname);
|
||||
fs.rmdirSync(dirname);
|
||||
|
|
|
|||
|
|
@ -20,13 +20,14 @@
|
|||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const fn = path.join(common.tmpDir, 'write.txt');
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const fn = path.join(tmpdir.path, 'write.txt');
|
||||
tmpdir.refresh();
|
||||
const file = fs.createWriteStream(fn, {
|
||||
highWaterMark: 10
|
||||
});
|
||||
|
|
|
|||
|
|
@ -20,14 +20,16 @@
|
|||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
const filepath = path.join(common.tmpDir, 'write.txt');
|
||||
|
||||
const filepath = path.join(tmpdir.path, 'write.txt');
|
||||
|
||||
const EXPECTED = '012345678910';
|
||||
|
||||
|
|
@ -58,7 +60,7 @@ function removeTestFile() {
|
|||
}
|
||||
|
||||
|
||||
common.refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
|
||||
// drain at 0, return false at 10.
|
||||
const file = fs.createWriteStream(filepath, {
|
||||
|
|
|
|||
|
|
@ -25,8 +25,10 @@ const assert = require('assert');
|
|||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
const filepath = path.join(common.tmpDir, 'write_pos.txt');
|
||||
|
||||
const filepath = path.join(tmpdir.path, 'write_pos.txt');
|
||||
|
||||
|
||||
const cb_expected = 'write open close write open close write open close ';
|
||||
|
|
@ -51,7 +53,7 @@ process.on('exit', function() {
|
|||
});
|
||||
|
||||
|
||||
common.refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
|
||||
|
||||
function run_test_1() {
|
||||
|
|
|
|||
|
|
@ -3,16 +3,18 @@ const common = require('../common');
|
|||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const doesNotExist = path.join(common.tmpDir, '__this_should_not_exist');
|
||||
const readOnlyFile = path.join(common.tmpDir, 'read_only_file');
|
||||
const readWriteFile = path.join(common.tmpDir, 'read_write_file');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const doesNotExist = path.join(tmpdir.path, '__this_should_not_exist');
|
||||
const readOnlyFile = path.join(tmpdir.path, 'read_only_file');
|
||||
const readWriteFile = path.join(tmpdir.path, 'read_write_file');
|
||||
|
||||
function createFileWithPerms(file, mode) {
|
||||
fs.writeFileSync(file, '');
|
||||
fs.chmodSync(file, mode);
|
||||
}
|
||||
|
||||
common.refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
createFileWithPerms(readOnlyFile, 0o444);
|
||||
createFileWithPerms(readWriteFile, 0o666);
|
||||
|
||||
|
|
|
|||
|
|
@ -36,10 +36,11 @@ const data = '南越国是前203年至前111年存在于岭南地区的一个国
|
|||
'历经五代君主。南越国是岭南地区的第一个有记载的政权国家,采用封建制和郡县制并存的制度,' +
|
||||
'它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n';
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
// test that empty file will be created and have content added
|
||||
const filename = join(common.tmpDir, 'append-sync.txt');
|
||||
const filename = join(tmpdir.path, 'append-sync.txt');
|
||||
|
||||
fs.appendFileSync(filename, data);
|
||||
|
||||
|
|
@ -48,7 +49,7 @@ const fileData = fs.readFileSync(filename);
|
|||
assert.strictEqual(Buffer.byteLength(data), fileData.length);
|
||||
|
||||
// test that appends data to a non empty file
|
||||
const filename2 = join(common.tmpDir, 'append-sync2.txt');
|
||||
const filename2 = join(tmpdir.path, 'append-sync2.txt');
|
||||
fs.writeFileSync(filename2, currentFileData);
|
||||
|
||||
fs.appendFileSync(filename2, data);
|
||||
|
|
@ -59,7 +60,7 @@ assert.strictEqual(Buffer.byteLength(data) + currentFileData.length,
|
|||
fileData2.length);
|
||||
|
||||
// test that appendFileSync accepts buffers
|
||||
const filename3 = join(common.tmpDir, 'append-sync3.txt');
|
||||
const filename3 = join(tmpdir.path, 'append-sync3.txt');
|
||||
fs.writeFileSync(filename3, currentFileData);
|
||||
|
||||
const buf = Buffer.from(data, 'utf8');
|
||||
|
|
@ -70,7 +71,7 @@ const fileData3 = fs.readFileSync(filename3);
|
|||
assert.strictEqual(buf.length + currentFileData.length, fileData3.length);
|
||||
|
||||
// test that appendFile accepts numbers.
|
||||
const filename4 = join(common.tmpDir, 'append-sync4.txt');
|
||||
const filename4 = join(tmpdir.path, 'append-sync4.txt');
|
||||
fs.writeFileSync(filename4, currentFileData, { mode: m });
|
||||
|
||||
fs.appendFileSync(filename4, num, { mode: m });
|
||||
|
|
@ -87,7 +88,7 @@ assert.strictEqual(Buffer.byteLength(String(num)) + currentFileData.length,
|
|||
fileData4.length);
|
||||
|
||||
// test that appendFile accepts file descriptors
|
||||
const filename5 = join(common.tmpDir, 'append-sync5.txt');
|
||||
const filename5 = join(tmpdir.path, 'append-sync5.txt');
|
||||
fs.writeFileSync(filename5, currentFileData);
|
||||
|
||||
const filename5fd = fs.openSync(filename5, 'a+', 0o600);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,9 @@ const assert = require('assert');
|
|||
const fs = require('fs');
|
||||
const join = require('path').join;
|
||||
|
||||
const filename = join(common.tmpDir, 'append.txt');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
const filename = join(tmpdir.path, 'append.txt');
|
||||
|
||||
const currentFileData = 'ABCD';
|
||||
|
||||
|
|
@ -40,7 +42,7 @@ const s = '南越国是前203年至前111年存在于岭南地区的一个国家
|
|||
|
||||
let ncallbacks = 0;
|
||||
|
||||
common.refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
|
||||
// test that empty file will be created and have content added
|
||||
fs.appendFile(filename, s, function(e) {
|
||||
|
|
@ -56,7 +58,7 @@ fs.appendFile(filename, s, function(e) {
|
|||
});
|
||||
|
||||
// test that appends data to a non empty file
|
||||
const filename2 = join(common.tmpDir, 'append2.txt');
|
||||
const filename2 = join(tmpdir.path, 'append2.txt');
|
||||
fs.writeFileSync(filename2, currentFileData);
|
||||
|
||||
fs.appendFile(filename2, s, function(e) {
|
||||
|
|
@ -73,7 +75,7 @@ fs.appendFile(filename2, s, function(e) {
|
|||
});
|
||||
|
||||
// test that appendFile accepts buffers
|
||||
const filename3 = join(common.tmpDir, 'append3.txt');
|
||||
const filename3 = join(tmpdir.path, 'append3.txt');
|
||||
fs.writeFileSync(filename3, currentFileData);
|
||||
|
||||
const buf = Buffer.from(s, 'utf8');
|
||||
|
|
@ -91,7 +93,7 @@ fs.appendFile(filename3, buf, function(e) {
|
|||
});
|
||||
|
||||
// test that appendFile accepts numbers.
|
||||
const filename4 = join(common.tmpDir, 'append4.txt');
|
||||
const filename4 = join(tmpdir.path, 'append4.txt');
|
||||
fs.writeFileSync(filename4, currentFileData);
|
||||
|
||||
const m = 0o600;
|
||||
|
|
@ -115,7 +117,7 @@ fs.appendFile(filename4, n, { mode: m }, function(e) {
|
|||
});
|
||||
|
||||
// test that appendFile accepts file descriptors
|
||||
const filename5 = join(common.tmpDir, 'append5.txt');
|
||||
const filename5 = join(tmpdir.path, 'append5.txt');
|
||||
fs.writeFileSync(filename5, currentFileData);
|
||||
|
||||
fs.open(filename5, 'a+', function(e, fd) {
|
||||
|
|
@ -146,7 +148,7 @@ fs.open(filename5, 'a+', function(e, fd) {
|
|||
|
||||
// test that a missing callback emits a warning, even if the last argument is a
|
||||
// function.
|
||||
const filename6 = join(common.tmpDir, 'append6.txt');
|
||||
const filename6 = join(tmpdir.path, 'append6.txt');
|
||||
const warn = 'Calling an asynchronous function without callback is deprecated.';
|
||||
common.expectWarning('DeprecationWarning', warn);
|
||||
fs.appendFile(filename6, console.log);
|
||||
|
|
|
|||
|
|
@ -6,16 +6,17 @@ const assert = require('assert');
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
assert.doesNotThrow(() => {
|
||||
fs.access(Buffer.from(common.tmpDir), common.mustCall((err) => {
|
||||
fs.access(Buffer.from(tmpdir.path), common.mustCall((err) => {
|
||||
assert.ifError(err);
|
||||
}));
|
||||
});
|
||||
|
||||
assert.doesNotThrow(() => {
|
||||
const buf = Buffer.from(path.join(common.tmpDir, 'a.txt'));
|
||||
const buf = Buffer.from(path.join(tmpdir.path, 'a.txt'));
|
||||
fs.open(buf, 'w+', common.mustCall((err, fd) => {
|
||||
assert.ifError(err);
|
||||
assert(fd);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
'use strict';
|
||||
const common = require('../common');
|
||||
require('../common');
|
||||
|
||||
// This test ensures that writeSync does support inputs which
|
||||
// are then correctly converted into string buffers.
|
||||
|
|
@ -8,10 +8,12 @@ const assert = require('assert');
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const filePath = path.join(common.tmpDir, 'test_buffer_type');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
const filePath = path.join(tmpdir.path, 'test_buffer_type');
|
||||
const v = [true, false, 0, 1, Infinity, () => {}, {}, [], undefined, null];
|
||||
|
||||
common.refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
|
||||
v.forEach((value) => {
|
||||
const fd = fs.openSync(filePath, 'w');
|
||||
|
|
|
|||
|
|
@ -71,10 +71,11 @@ if (common.isWindows) {
|
|||
mode_sync = 0o644;
|
||||
}
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
const file1 = path.join(common.tmpDir, 'a.js');
|
||||
const file2 = path.join(common.tmpDir, 'a1.js');
|
||||
const file1 = path.join(tmpdir.path, 'a.js');
|
||||
const file2 = path.join(tmpdir.path, 'a1.js');
|
||||
|
||||
// Create file1.
|
||||
fs.closeSync(fs.openSync(file1, 'w'));
|
||||
|
|
@ -121,7 +122,7 @@ fs.open(file2, 'w', common.mustCall((err, fd) => {
|
|||
|
||||
// lchmod
|
||||
if (fs.lchmod) {
|
||||
const link = path.join(common.tmpDir, 'symbolic-link');
|
||||
const link = path.join(tmpdir.path, 'symbolic-link');
|
||||
|
||||
fs.symlinkSync(file2, link);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
'use strict';
|
||||
const common = require('../common');
|
||||
const fixtures = require('../common/fixtures');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const src = fixtures.path('a.js');
|
||||
const dest = path.join(common.tmpDir, 'copyfile.out');
|
||||
const dest = path.join(tmpdir.path, 'copyfile.out');
|
||||
const { COPYFILE_EXCL, UV_FS_COPYFILE_EXCL } = fs.constants;
|
||||
|
||||
function verify(src, dest) {
|
||||
|
|
@ -19,7 +20,7 @@ function verify(src, dest) {
|
|||
assert.strictEqual(srcStat.size, destStat.size);
|
||||
}
|
||||
|
||||
common.refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
|
||||
// Verify that flags are defined.
|
||||
assert.strictEqual(typeof COPYFILE_EXCL, 'number');
|
||||
|
|
|
|||
|
|
@ -23,15 +23,16 @@
|
|||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const fixtures = require('../common/fixtures');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const fileFixture = fixtures.path('a.js');
|
||||
const fileTemp = path.join(common.tmpDir, 'a.js');
|
||||
const fileTemp = path.join(tmpdir.path, 'a.js');
|
||||
|
||||
// Copy fixtures to temp.
|
||||
common.refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
fs.copyFileSync(fileFixture, fileTemp);
|
||||
|
||||
fs.open(fileTemp, 'a', 0o777, common.mustCall(function(err, fd) {
|
||||
|
|
|
|||
|
|
@ -4,11 +4,12 @@ const assert = require('assert');
|
|||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
// test creating and reading hard link
|
||||
const srcPath = path.join(common.tmpDir, 'hardlink-target.txt');
|
||||
const dstPath = path.join(common.tmpDir, 'link1.js');
|
||||
const srcPath = path.join(tmpdir.path, 'hardlink-target.txt');
|
||||
const dstPath = path.join(tmpdir.path, 'link1.js');
|
||||
fs.writeFileSync(srcPath, 'hello world');
|
||||
|
||||
function callback(err) {
|
||||
|
|
|
|||
|
|
@ -28,12 +28,14 @@ const fs = require('fs');
|
|||
const path = require('path');
|
||||
const assert = require('assert');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
// make a path that will be at least 260 chars long.
|
||||
const fileNameLen = Math.max(260 - common.tmpDir.length - 1, 1);
|
||||
const fileName = path.join(common.tmpDir, 'x'.repeat(fileNameLen));
|
||||
const fileNameLen = Math.max(260 - tmpdir.path.length - 1, 1);
|
||||
const fileName = path.join(tmpdir.path, 'x'.repeat(fileNameLen));
|
||||
const fullPath = path.resolve(fileName);
|
||||
|
||||
common.refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
|
||||
console.log({
|
||||
filenameLength: fileName.length,
|
||||
|
|
|
|||
|
|
@ -8,12 +8,13 @@ const callbackThrowValues = [null, true, false, 0, 1, 'foo', /foo/, [], {}];
|
|||
const { sep } = require('path');
|
||||
const warn = 'Calling an asynchronous function without callback is deprecated.';
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
function testMakeCallback(cb) {
|
||||
return function() {
|
||||
// fs.mkdtemp() calls makeCallback() on its third argument
|
||||
fs.mkdtemp(`${common.tmpDir}${sep}`, {}, cb);
|
||||
fs.mkdtemp(`${tmpdir.path}${sep}`, {}, cb);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,9 +4,10 @@ const common = require('../common');
|
|||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const d = path.join(common.tmpDir, 'dir');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const d = path.join(tmpdir.path, 'dir');
|
||||
|
||||
common.refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
|
||||
// Make sure the directory does not exist
|
||||
assert(!common.fileExists(d));
|
||||
|
|
|
|||
|
|
@ -24,10 +24,11 @@ const common = require('../common');
|
|||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
{
|
||||
const pathname = `${common.tmpDir}/test1`;
|
||||
const pathname = `${tmpdir.path}/test1`;
|
||||
|
||||
fs.mkdir(pathname, common.mustCall(function(err) {
|
||||
assert.strictEqual(err, null);
|
||||
|
|
@ -36,7 +37,7 @@ common.refreshTmpDir();
|
|||
}
|
||||
|
||||
{
|
||||
const pathname = `${common.tmpDir}/test2`;
|
||||
const pathname = `${tmpdir.path}/test2`;
|
||||
|
||||
fs.mkdir(pathname, 0o777, common.mustCall(function(err) {
|
||||
assert.strictEqual(err, null);
|
||||
|
|
@ -45,7 +46,7 @@ common.refreshTmpDir();
|
|||
}
|
||||
|
||||
{
|
||||
const pathname = `${common.tmpDir}/test3`;
|
||||
const pathname = `${tmpdir.path}/test3`;
|
||||
|
||||
fs.mkdirSync(pathname);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,14 +5,15 @@ const assert = require('assert');
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
const tmpFolder = fs.mkdtempSync(path.join(common.tmpDir, 'foo.'));
|
||||
const tmpFolder = fs.mkdtempSync(path.join(tmpdir.path, 'foo.'));
|
||||
|
||||
assert.strictEqual(path.basename(tmpFolder).length, 'foo.XXXXXX'.length);
|
||||
assert(common.fileExists(tmpFolder));
|
||||
|
||||
const utf8 = fs.mkdtempSync(path.join(common.tmpDir, '\u0222abc.'));
|
||||
const utf8 = fs.mkdtempSync(path.join(tmpdir.path, '\u0222abc.'));
|
||||
assert.strictEqual(Buffer.byteLength(path.basename(utf8)),
|
||||
Buffer.byteLength('\u0222abc.XXXXXX'));
|
||||
assert(common.fileExists(utf8));
|
||||
|
|
@ -23,13 +24,13 @@ function handler(err, folder) {
|
|||
assert.strictEqual(this, null);
|
||||
}
|
||||
|
||||
fs.mkdtemp(path.join(common.tmpDir, 'bar.'), common.mustCall(handler));
|
||||
fs.mkdtemp(path.join(tmpdir.path, 'bar.'), common.mustCall(handler));
|
||||
|
||||
// Same test as above, but making sure that passing an options object doesn't
|
||||
// affect the way the callback function is handled.
|
||||
fs.mkdtemp(path.join(common.tmpDir, 'bar.'), {}, common.mustCall(handler));
|
||||
fs.mkdtemp(path.join(tmpdir.path, 'bar.'), {}, common.mustCall(handler));
|
||||
|
||||
// Making sure that not passing a callback doesn't crash, as a default function
|
||||
// is passed internally.
|
||||
assert.doesNotThrow(() => fs.mkdtemp(path.join(common.tmpDir, 'bar-')));
|
||||
assert.doesNotThrow(() => fs.mkdtemp(path.join(common.tmpDir, 'bar-'), {}));
|
||||
assert.doesNotThrow(() => fs.mkdtemp(path.join(tmpdir.path, 'bar-')));
|
||||
assert.doesNotThrow(() => fs.mkdtemp(path.join(tmpdir.path, 'bar-'), {}));
|
||||
|
|
|
|||
|
|
@ -4,9 +4,10 @@ const common = require('../common');
|
|||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const tempFile = path.join(common.tmpDir, 'fs-non-number-arguments-throw');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const tempFile = path.join(tmpdir.path, 'fs-non-number-arguments-throw');
|
||||
|
||||
common.refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
fs.writeFileSync(tempFile, 'abc\ndef');
|
||||
|
||||
// a sanity check when using numbers instead of strings
|
||||
|
|
|
|||
|
|
@ -84,8 +84,9 @@ assert.throws(
|
|||
);
|
||||
|
||||
if (common.isLinux || common.isOSX) {
|
||||
common.refreshTmpDir();
|
||||
const file = path.join(common.tmpDir, 'a.js');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
const file = path.join(tmpdir.path, 'a.js');
|
||||
fs.copyFileSync(fixtures.path('a.js'), file);
|
||||
fs.open(file, O_DSYNC, common.mustCall(assert.ifError));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,15 @@
|
|||
'use strict';
|
||||
const common = require('../common');
|
||||
require('../common');
|
||||
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
// O_WRONLY without O_CREAT shall fail with ENOENT
|
||||
const pathNE = path.join(common.tmpDir, 'file-should-not-exist');
|
||||
const pathNE = path.join(tmpdir.path, 'file-should-not-exist');
|
||||
assert.throws(
|
||||
() => fs.openSync(pathNE, fs.constants.O_WRONLY),
|
||||
(e) => e.code === 'ENOENT'
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ const path = require('path');
|
|||
|
||||
const errHandler = (e) => assert.ifError(e);
|
||||
const options = Object.freeze({});
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
{
|
||||
assert.doesNotThrow(() =>
|
||||
|
|
@ -31,8 +32,8 @@ common.refreshTmpDir();
|
|||
}
|
||||
|
||||
if (common.canCreateSymLink()) {
|
||||
const sourceFile = path.resolve(common.tmpDir, 'test-readlink');
|
||||
const linkFile = path.resolve(common.tmpDir, 'test-readlink-link');
|
||||
const sourceFile = path.resolve(tmpdir.path, 'test-readlink');
|
||||
const linkFile = path.resolve(tmpdir.path, 'test-readlink-link');
|
||||
|
||||
fs.writeFileSync(sourceFile, '');
|
||||
fs.symlinkSync(sourceFile, linkFile);
|
||||
|
|
@ -44,7 +45,7 @@ if (common.canCreateSymLink()) {
|
|||
}
|
||||
|
||||
{
|
||||
const fileName = path.resolve(common.tmpDir, 'writeFile');
|
||||
const fileName = path.resolve(tmpdir.path, 'writeFile');
|
||||
assert.doesNotThrow(() => fs.writeFileSync(fileName, 'ABCD', options));
|
||||
assert.doesNotThrow(() =>
|
||||
fs.writeFile(fileName, 'ABCD', options, common.mustCall(errHandler))
|
||||
|
|
@ -52,7 +53,7 @@ if (common.canCreateSymLink()) {
|
|||
}
|
||||
|
||||
{
|
||||
const fileName = path.resolve(common.tmpDir, 'appendFile');
|
||||
const fileName = path.resolve(tmpdir.path, 'appendFile');
|
||||
assert.doesNotThrow(() => fs.appendFileSync(fileName, 'ABCD', options));
|
||||
assert.doesNotThrow(() =>
|
||||
fs.appendFile(fileName, 'ABCD', options, common.mustCall(errHandler))
|
||||
|
|
@ -82,7 +83,7 @@ if (common.canCreateSymLink()) {
|
|||
}
|
||||
|
||||
{
|
||||
const tempFileName = path.resolve(common.tmpDir, 'mkdtemp-');
|
||||
const tempFileName = path.resolve(tmpdir.path, 'mkdtemp-');
|
||||
assert.doesNotThrow(() => fs.mkdtempSync(tempFileName, options));
|
||||
assert.doesNotThrow(() =>
|
||||
fs.mkdtemp(tempFileName, options, common.mustCall(errHandler))
|
||||
|
|
@ -90,7 +91,7 @@ if (common.canCreateSymLink()) {
|
|||
}
|
||||
|
||||
{
|
||||
const fileName = path.resolve(common.tmpDir, 'streams');
|
||||
const fileName = path.resolve(tmpdir.path, 'streams');
|
||||
assert.doesNotThrow(() => {
|
||||
fs.WriteStream(fileName, options).once('open', common.mustCall(() => {
|
||||
assert.doesNotThrow(() => fs.ReadStream(fileName, options));
|
||||
|
|
|
|||
|
|
@ -20,9 +20,10 @@ const exists = promisify(fs.exists);
|
|||
}));
|
||||
}
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
{
|
||||
const filename = path.join(common.tmpDir, 'write-promise.txt');
|
||||
const filename = path.join(tmpdir.path, 'write-promise.txt');
|
||||
const fd = fs.openSync(filename, 'w');
|
||||
write(fd, Buffer.from('foobar')).then(common.mustCall((obj) => {
|
||||
assert.strictEqual(typeof obj.bytesWritten, 'number');
|
||||
|
|
|
|||
|
|
@ -20,15 +20,16 @@
|
|||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
require('../common');
|
||||
const fs = require('fs');
|
||||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
const file = path.join(common.tmpDir, '/read_stream_fd_test.txt');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const file = path.join(tmpdir.path, '/read_stream_fd_test.txt');
|
||||
const input = 'hello world';
|
||||
|
||||
let output = '';
|
||||
common.refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
fs.writeFileSync(file, input);
|
||||
|
||||
const fd = fs.openSync(file, 'r');
|
||||
|
|
|
|||
|
|
@ -176,8 +176,9 @@ if (!common.isWindows) {
|
|||
// Verify that end works when start is not specified, and we do not try to
|
||||
// use positioned reads. This makes sure that this keeps working for
|
||||
// non-seekable file descriptors.
|
||||
common.refreshTmpDir();
|
||||
const filename = `${common.tmpDir}/foo.pipe`;
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
const filename = `${tmpdir.path}/foo.pipe`;
|
||||
const mkfifoResult = child_process.spawnSync('mkfifo', [filename]);
|
||||
if (!mkfifoResult.error) {
|
||||
child_process.exec(`echo "xyz foobar" > '${filename}'`);
|
||||
|
|
|
|||
|
|
@ -8,9 +8,10 @@ const path = require('path');
|
|||
const fs = require('fs');
|
||||
const assert = require('assert');
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
const filename = '\uD83D\uDC04';
|
||||
const root = Buffer.from(`${common.tmpDir}${path.sep}`);
|
||||
const root = Buffer.from(`${tmpdir.path}${path.sep}`);
|
||||
const filebuff = Buffer.from(filename, 'ucs2');
|
||||
const fullpath = Buffer.concat([root, filebuff]);
|
||||
|
||||
|
|
@ -22,7 +23,7 @@ try {
|
|||
throw e;
|
||||
}
|
||||
|
||||
fs.readdir(common.tmpDir, 'ucs2', common.mustCall((err, list) => {
|
||||
fs.readdir(tmpdir.path, 'ucs2', common.mustCall((err, list) => {
|
||||
assert.ifError(err);
|
||||
assert.strictEqual(1, list.length);
|
||||
const fn = list[0];
|
||||
|
|
|
|||
|
|
@ -4,11 +4,13 @@ const common = require('../common');
|
|||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
|
||||
const readdirDir = common.tmpDir;
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
const readdirDir = tmpdir.path;
|
||||
const files = ['empty', 'files', 'for', 'just', 'testing'];
|
||||
|
||||
// Make sure tmp directory is clean
|
||||
common.refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
|
||||
// Create the necessary files
|
||||
files.forEach(function(currentFile) {
|
||||
|
|
|
|||
|
|
@ -18,9 +18,11 @@ if (process.argv[2] === 'child') {
|
|||
return;
|
||||
}
|
||||
|
||||
const filename = path.join(common.tmpDir, '/readfile_pipe_large_test.txt');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
const filename = path.join(tmpdir.path, '/readfile_pipe_large_test.txt');
|
||||
const dataExpected = 'a'.repeat(999999);
|
||||
common.refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
fs.writeFileSync(filename, dataExpected);
|
||||
|
||||
const exec = require('child_process').exec;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
require('../common');
|
||||
|
||||
// Test that unlink succeeds immediately after readFile completes.
|
||||
|
||||
|
|
@ -28,10 +28,12 @@ const assert = require('assert');
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const fileName = path.resolve(common.tmpDir, 'test.bin');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
const fileName = path.resolve(tmpdir.path, 'test.bin');
|
||||
const buf = Buffer.alloc(512 * 1024, 42);
|
||||
|
||||
common.refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
|
||||
fs.writeFileSync(fileName, buf);
|
||||
|
||||
|
|
|
|||
|
|
@ -15,9 +15,11 @@ if (process.argv[2] === 'child') {
|
|||
return;
|
||||
}
|
||||
|
||||
const filename = path.join(common.tmpDir, '/readfilesync_pipe_large_test.txt');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
const filename = path.join(tmpdir.path, '/readfilesync_pipe_large_test.txt');
|
||||
const dataExpected = 'a'.repeat(999999);
|
||||
common.refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
fs.writeFileSync(filename, dataExpected);
|
||||
|
||||
const exec = require('child_process').exec;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
'use strict';
|
||||
const common = require('../common');
|
||||
const fixtures = require('../common/fixtures');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
|
|
@ -31,9 +32,9 @@ let async_completed = 0;
|
|||
let async_expected = 0;
|
||||
const unlink = [];
|
||||
let skipSymlinks = false;
|
||||
const tmpDir = common.tmpDir;
|
||||
const tmpDir = tmpdir.path;
|
||||
|
||||
common.refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
|
||||
let root = '/';
|
||||
let assertEqualPath = assert.strictEqual;
|
||||
|
|
@ -400,6 +401,8 @@ function test_up_multiple(cb) {
|
|||
cleanup();
|
||||
}
|
||||
setup();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
fs.mkdirSync(tmp('a'), 0o755);
|
||||
fs.mkdirSync(tmp('a/b'), 0o755);
|
||||
fs.symlinkSync('..', tmp('a/d'), 'dir');
|
||||
|
|
|
|||
|
|
@ -20,14 +20,16 @@
|
|||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
require('../common');
|
||||
const fs = require('fs');
|
||||
const assert = require('assert');
|
||||
const join = require('path').join;
|
||||
|
||||
const filename = join(common.tmpDir, 'out.txt');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
common.refreshTmpDir();
|
||||
const filename = join(tmpdir.path, 'out.txt');
|
||||
|
||||
tmpdir.refresh();
|
||||
|
||||
const fd = fs.openSync(filename, 'w');
|
||||
|
||||
|
|
|
|||
|
|
@ -23,15 +23,16 @@
|
|||
const common = require('../common');
|
||||
const fs = require('fs');
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
test1(fs.createReadStream(__filename));
|
||||
test2(fs.createReadStream(__filename));
|
||||
test3(fs.createReadStream(__filename));
|
||||
|
||||
test1(fs.createWriteStream(`${common.tmpDir}/dummy1`));
|
||||
test2(fs.createWriteStream(`${common.tmpDir}/dummy2`));
|
||||
test3(fs.createWriteStream(`${common.tmpDir}/dummy3`));
|
||||
test1(fs.createWriteStream(`${tmpdir.path}/dummy1`));
|
||||
test2(fs.createWriteStream(`${tmpdir.path}/dummy2`));
|
||||
test3(fs.createWriteStream(`${tmpdir.path}/dummy3`));
|
||||
|
||||
function test1(stream) {
|
||||
stream.destroy();
|
||||
|
|
|
|||
|
|
@ -28,12 +28,14 @@ const assert = require('assert');
|
|||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const linkPath1 = path.join(common.tmpDir, 'junction1');
|
||||
const linkPath2 = path.join(common.tmpDir, 'junction2');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
const linkPath1 = path.join(tmpdir.path, 'junction1');
|
||||
const linkPath2 = path.join(tmpdir.path, 'junction2');
|
||||
const linkTarget = fixtures.fixturesDir;
|
||||
const linkData = fixtures.fixturesDir;
|
||||
|
||||
common.refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
|
||||
// Test fs.symlink()
|
||||
fs.symlink(linkData, linkPath1, 'junction', common.mustCall(function(err) {
|
||||
|
|
|
|||
|
|
@ -26,11 +26,13 @@ const assert = require('assert');
|
|||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
// test creating and reading symbolic link
|
||||
const linkData = fixtures.path('cycles/');
|
||||
const linkPath = path.join(common.tmpDir, 'cycles_link');
|
||||
const linkPath = path.join(tmpdir.path, 'cycles_link');
|
||||
|
||||
common.refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
|
||||
fs.symlink(linkData, linkPath, 'junction', common.mustCall(function(err) {
|
||||
assert.ifError(err);
|
||||
|
|
|
|||
|
|
@ -32,11 +32,12 @@ const fs = require('fs');
|
|||
let linkTime;
|
||||
let fileTime;
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
// test creating and reading symbolic link
|
||||
const linkData = fixtures.path('/cycles/root.js');
|
||||
const linkPath = path.join(common.tmpDir, 'symlink1.js');
|
||||
const linkPath = path.join(tmpdir.path, 'symlink1.js');
|
||||
|
||||
fs.symlink(linkData, linkPath, common.mustCall(function(err) {
|
||||
assert.ifError(err);
|
||||
|
|
|
|||
|
|
@ -21,9 +21,10 @@ if (process.argv[2] === 'child') {
|
|||
return;
|
||||
}
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
const filename = path.join(common.tmpDir, 'stdout');
|
||||
const filename = path.join(tmpdir.path, 'stdout');
|
||||
const stdoutFd = fs.openSync(filename, 'w');
|
||||
|
||||
const proc = spawn(process.execPath, [__filename, 'child'], {
|
||||
|
|
|
|||
|
|
@ -24,9 +24,11 @@ const common = require('../common');
|
|||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
|
||||
const filename = `${common.tmpDir}/truncate-file.txt`;
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
common.refreshTmpDir();
|
||||
const filename = `${tmpdir.path}/truncate-file.txt`;
|
||||
|
||||
tmpdir.refresh();
|
||||
|
||||
// Synchronous test.
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@ const common = require('../common');
|
|||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const tmp = common.tmpDir;
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const tmp = tmpdir.path;
|
||||
tmpdir.refresh();
|
||||
const filename = path.resolve(tmp, 'truncate-file.txt');
|
||||
|
||||
fs.writeFileSync(filename, 'hello world', 'utf8');
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
'use strict';
|
||||
const common = require('../common');
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const tmp = common.tmpDir;
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const tmp = tmpdir.path;
|
||||
|
||||
common.refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
|
||||
const filename = path.resolve(tmp, 'truncate-sync-file.txt');
|
||||
|
||||
|
|
|
|||
|
|
@ -24,11 +24,12 @@ const common = require('../common');
|
|||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const tmp = common.tmpDir;
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const tmp = tmpdir.path;
|
||||
const filename = path.resolve(tmp, 'truncate-file.txt');
|
||||
const data = Buffer.alloc(1024 * 16, 'x');
|
||||
|
||||
common.refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
|
||||
let stat;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ const assert = require('assert');
|
|||
const util = require('util');
|
||||
const fs = require('fs');
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
let tests_ok = 0;
|
||||
let tests_run = 0;
|
||||
|
|
@ -73,8 +74,8 @@ function testIt(atime, mtime, callback) {
|
|||
// test synchronized code paths, these functions throw on failure
|
||||
//
|
||||
function syncTests() {
|
||||
fs.utimesSync(common.tmpDir, atime, mtime);
|
||||
expect_ok('utimesSync', common.tmpDir, undefined, atime, mtime);
|
||||
fs.utimesSync(tmpdir.path, atime, mtime);
|
||||
expect_ok('utimesSync', tmpdir.path, undefined, atime, mtime);
|
||||
tests_run++;
|
||||
|
||||
// some systems don't have futimes
|
||||
|
|
@ -109,17 +110,17 @@ function testIt(atime, mtime, callback) {
|
|||
//
|
||||
// test async code paths
|
||||
//
|
||||
fs.utimes(common.tmpDir, atime, mtime, common.mustCall(function(err) {
|
||||
expect_ok('utimes', common.tmpDir, err, atime, mtime);
|
||||
fs.utimes(tmpdir.path, atime, mtime, common.mustCall(function(err) {
|
||||
expect_ok('utimes', tmpdir.path, err, atime, mtime);
|
||||
|
||||
fs.utimes('foobarbaz', atime, mtime, common.mustCall(function(err) {
|
||||
expect_errno('utimes', 'foobarbaz', err, 'ENOENT');
|
||||
|
||||
// don't close this fd
|
||||
if (common.isWindows) {
|
||||
fd = fs.openSync(common.tmpDir, 'r+');
|
||||
fd = fs.openSync(tmpdir.path, 'r+');
|
||||
} else {
|
||||
fd = fs.openSync(common.tmpDir, 'r');
|
||||
fd = fs.openSync(tmpdir.path, 'r');
|
||||
}
|
||||
|
||||
fs.futimes(fd, atime, mtime, common.mustCall(function(err) {
|
||||
|
|
@ -139,7 +140,7 @@ function testIt(atime, mtime, callback) {
|
|||
tests_run++;
|
||||
}
|
||||
|
||||
const stats = fs.statSync(common.tmpDir);
|
||||
const stats = fs.statSync(tmpdir.path);
|
||||
|
||||
// run tests
|
||||
const runTest = common.mustCall(testIt, 6);
|
||||
|
|
@ -168,7 +169,7 @@ process.on('exit', function() {
|
|||
|
||||
|
||||
// Ref: https://github.com/nodejs/node/issues/13255
|
||||
const path = `${common.tmpDir}/test-utimes-precision`;
|
||||
const path = `${tmpdir.path}/test-utimes-precision`;
|
||||
fs.writeFileSync(path, '');
|
||||
|
||||
// test Y2K38 for all platforms [except 'arm', and 'SunOS']
|
||||
|
|
|
|||
|
|
@ -22,10 +22,11 @@ if (common.isAIX)
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
const fn = '新建文夹件.txt';
|
||||
const a = path.join(common.tmpDir, fn);
|
||||
const a = path.join(tmpdir.path, fn);
|
||||
|
||||
const watchers = new Set();
|
||||
|
||||
|
|
@ -42,7 +43,7 @@ function unregisterWatcher(watcher) {
|
|||
}
|
||||
|
||||
const watcher1 = fs.watch(
|
||||
common.tmpDir,
|
||||
tmpdir.path,
|
||||
{ encoding: 'hex' },
|
||||
(event, filename) => {
|
||||
if (['e696b0e5bbbae69687e5a4b9e4bbb62e747874', null].includes(filename))
|
||||
|
|
@ -52,7 +53,7 @@ const watcher1 = fs.watch(
|
|||
registerWatcher(watcher1);
|
||||
|
||||
const watcher2 = fs.watch(
|
||||
common.tmpDir,
|
||||
tmpdir.path,
|
||||
(event, filename) => {
|
||||
if ([fn, null].includes(filename))
|
||||
done(watcher2);
|
||||
|
|
@ -61,7 +62,7 @@ const watcher2 = fs.watch(
|
|||
registerWatcher(watcher2);
|
||||
|
||||
const watcher3 = fs.watch(
|
||||
common.tmpDir,
|
||||
tmpdir.path,
|
||||
{ encoding: 'buffer' },
|
||||
(event, filename) => {
|
||||
if (filename instanceof Buffer && filename.toString('utf8') === fn)
|
||||
|
|
|
|||
|
|
@ -9,10 +9,12 @@ const assert = require('assert');
|
|||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const testDir = common.tmpDir;
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
const testDir = tmpdir.path;
|
||||
const filenameOne = 'watch.txt';
|
||||
|
||||
common.refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
|
||||
const testsubdir = fs.mkdtempSync(testDir + path.sep);
|
||||
const relativePathOne = path.join(path.basename(testsubdir), filenameOne);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class WatchTestCase {
|
|||
this.field = field;
|
||||
this.shouldSkip = !shouldInclude;
|
||||
}
|
||||
get dirPath() { return join(common.tmpDir, this.dirName); }
|
||||
get dirPath() { return join(tmpdir.path, this.dirName); }
|
||||
get filePath() { return join(this.dirPath, this.fileName); }
|
||||
}
|
||||
|
||||
|
|
@ -35,7 +35,8 @@ const cases = [
|
|||
)
|
||||
];
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
for (const testCase of cases) {
|
||||
if (testCase.shouldSkip) continue;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ const assert = require('assert');
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
// Basic usage tests.
|
||||
assert.throws(function() {
|
||||
fs.watchFile('./some-file');
|
||||
|
|
@ -18,7 +20,7 @@ assert.throws(function() {
|
|||
fs.watchFile(new Object(), common.mustNotCall());
|
||||
}, /Path must be a string/);
|
||||
|
||||
const enoentFile = path.join(common.tmpDir, 'non-existent-file');
|
||||
const enoentFile = path.join(tmpdir.path, 'non-existent-file');
|
||||
const expectedStatObject = new fs.Stats(
|
||||
0, // dev
|
||||
0, // mode
|
||||
|
|
@ -36,7 +38,7 @@ const expectedStatObject = new fs.Stats(
|
|||
Date.UTC(1970, 0, 1, 0, 0, 0) // birthtime
|
||||
);
|
||||
|
||||
common.refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
|
||||
// If the file initially didn't exist, and gets created at a later point of
|
||||
// time, the callback should be invoked again with proper values in stat object
|
||||
|
|
@ -67,7 +69,7 @@ fs.watchFile(enoentFile, { interval: 0 }, common.mustCall(function(curr, prev) {
|
|||
// Watch events should callback with a filename on supported systems.
|
||||
// Omitting AIX. It works but not reliably.
|
||||
if (common.isLinux || common.isOSX || common.isWindows) {
|
||||
const dir = path.join(common.tmpDir, 'watch');
|
||||
const dir = path.join(tmpdir.path, 'watch');
|
||||
|
||||
fs.mkdir(dir, common.mustCall(function(err) {
|
||||
if (err) assert.fail(err);
|
||||
|
|
|
|||
|
|
@ -26,11 +26,12 @@ const path = require('path');
|
|||
const fs = require('fs');
|
||||
const expected = Buffer.from('hello');
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
// fs.write with all parameters provided:
|
||||
{
|
||||
const filename = path.join(common.tmpDir, 'write1.txt');
|
||||
const filename = path.join(tmpdir.path, 'write1.txt');
|
||||
fs.open(filename, 'w', 0o644, common.mustCall((err, fd) => {
|
||||
assert.ifError(err);
|
||||
|
||||
|
|
@ -50,7 +51,7 @@ common.refreshTmpDir();
|
|||
|
||||
// fs.write with a buffer, without the length parameter:
|
||||
{
|
||||
const filename = path.join(common.tmpDir, 'write2.txt');
|
||||
const filename = path.join(tmpdir.path, 'write2.txt');
|
||||
fs.open(filename, 'w', 0o644, common.mustCall((err, fd) => {
|
||||
assert.ifError(err);
|
||||
|
||||
|
|
@ -70,7 +71,7 @@ common.refreshTmpDir();
|
|||
|
||||
// fs.write with a buffer, without the offset and length parameters:
|
||||
{
|
||||
const filename = path.join(common.tmpDir, 'write3.txt');
|
||||
const filename = path.join(tmpdir.path, 'write3.txt');
|
||||
fs.open(filename, 'w', 0o644, common.mustCall(function(err, fd) {
|
||||
assert.ifError(err);
|
||||
|
||||
|
|
@ -90,7 +91,7 @@ common.refreshTmpDir();
|
|||
|
||||
// fs.write with the offset passed as undefined followed by the callback:
|
||||
{
|
||||
const filename = path.join(common.tmpDir, 'write4.txt');
|
||||
const filename = path.join(tmpdir.path, 'write4.txt');
|
||||
fs.open(filename, 'w', 0o644, common.mustCall(function(err, fd) {
|
||||
assert.ifError(err);
|
||||
|
||||
|
|
@ -110,7 +111,7 @@ common.refreshTmpDir();
|
|||
|
||||
// fs.write with offset and length passed as undefined followed by the callback:
|
||||
{
|
||||
const filename = path.join(common.tmpDir, 'write5.txt');
|
||||
const filename = path.join(tmpdir.path, 'write5.txt');
|
||||
fs.open(filename, 'w', 0o644, common.mustCall((err, fd) => {
|
||||
assert.ifError(err);
|
||||
|
||||
|
|
@ -130,7 +131,7 @@ common.refreshTmpDir();
|
|||
|
||||
// fs.write with a Uint8Array, without the offset and length parameters:
|
||||
{
|
||||
const filename = path.join(common.tmpDir, 'write6.txt');
|
||||
const filename = path.join(tmpdir.path, 'write6.txt');
|
||||
fs.open(filename, 'w', 0o644, common.mustCall((err, fd) => {
|
||||
assert.ifError(err);
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
require('../common');
|
||||
const join = require('path').join;
|
||||
const util = require('util');
|
||||
const fs = require('fs');
|
||||
|
|
@ -46,9 +46,10 @@ let data = [
|
|||
|
||||
data = data.join('\n');
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
const buf = Buffer.from(data, 'base64');
|
||||
fs.writeFileSync(join(common.tmpDir, 'test.jpg'), buf);
|
||||
fs.writeFileSync(join(tmpdir.path, 'test.jpg'), buf);
|
||||
|
||||
util.log('Done!');
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ const path = require('path');
|
|||
if (!common.isWindows)
|
||||
common.skip('This test is for Windows only.');
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
const DATA_VALUE = 'hello';
|
||||
|
||||
|
|
@ -17,7 +18,7 @@ const DATA_VALUE = 'hello';
|
|||
const RESERVED_CHARACTERS = '<>"|?*';
|
||||
|
||||
[...RESERVED_CHARACTERS].forEach((ch) => {
|
||||
const pathname = path.join(common.tmpDir, `somefile_${ch}`);
|
||||
const pathname = path.join(tmpdir.path, `somefile_${ch}`);
|
||||
assert.throws(
|
||||
() => {
|
||||
fs.writeFileSync(pathname, DATA_VALUE);
|
||||
|
|
@ -28,7 +29,7 @@ const RESERVED_CHARACTERS = '<>"|?*';
|
|||
|
||||
// Test for ':' (NTFS data streams).
|
||||
// Refs: https://msdn.microsoft.com/en-us/library/windows/desktop/bb540537.aspx
|
||||
const pathname = path.join(common.tmpDir, 'foo:bar');
|
||||
const pathname = path.join(tmpdir.path, 'foo:bar');
|
||||
fs.writeFileSync(pathname, DATA_VALUE);
|
||||
|
||||
let content = '';
|
||||
|
|
|
|||
|
|
@ -46,10 +46,11 @@ if (common.isWindows) {
|
|||
mode = 0o755;
|
||||
}
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
// Test writeFileSync
|
||||
const file1 = path.join(common.tmpDir, 'testWriteFileSync.txt');
|
||||
const file1 = path.join(tmpdir.path, 'testWriteFileSync.txt');
|
||||
|
||||
fs.writeFileSync(file1, '123', { mode });
|
||||
|
||||
|
|
@ -59,7 +60,7 @@ assert.strictEqual(content, '123');
|
|||
assert.strictEqual(fs.statSync(file1).mode & 0o777, mode);
|
||||
|
||||
// Test appendFileSync
|
||||
const file2 = path.join(common.tmpDir, 'testAppendFileSync.txt');
|
||||
const file2 = path.join(tmpdir.path, 'testAppendFileSync.txt');
|
||||
|
||||
fs.appendFileSync(file2, 'abc', { mode });
|
||||
|
||||
|
|
@ -69,7 +70,7 @@ assert.strictEqual(content, 'abc');
|
|||
assert.strictEqual(fs.statSync(file2).mode & mode, mode);
|
||||
|
||||
// Test writeFileSync with file descriptor
|
||||
const file3 = path.join(common.tmpDir, 'testWriteFileSyncFd.txt');
|
||||
const file3 = path.join(tmpdir.path, 'testWriteFileSyncFd.txt');
|
||||
|
||||
const fd = fs.openSync(file3, 'w+', mode);
|
||||
fs.writeFileSync(fd, '123');
|
||||
|
|
|
|||
|
|
@ -4,9 +4,10 @@ const assert = require('assert');
|
|||
const fs = require('fs');
|
||||
const join = require('path').join;
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
const filename = join(common.tmpDir, 'test.txt');
|
||||
const filename = join(tmpdir.path, 'test.txt');
|
||||
|
||||
const s = '南越国是前203年至前111年存在于岭南地区的一个国家,国都位于番禺,疆域包括今天中国的广东、' +
|
||||
'广西两省区的大部份地区,福建省、湖南、贵州、云南的一小部份地区和越南的北部。' +
|
||||
|
|
|
|||
|
|
@ -25,9 +25,10 @@ const assert = require('assert');
|
|||
const fs = require('fs');
|
||||
const join = require('path').join;
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
const filename = join(common.tmpDir, 'test.txt');
|
||||
const filename = join(tmpdir.path, 'test.txt');
|
||||
|
||||
const n = 220;
|
||||
const s = '南越国是前203年至前111年存在于岭南地区的一个国家,国都位于番禺,疆域包括今天中国的广东、' +
|
||||
|
|
@ -48,7 +49,7 @@ fs.writeFile(filename, s, common.mustCall(function(e) {
|
|||
}));
|
||||
|
||||
// test that writeFile accepts buffers
|
||||
const filename2 = join(common.tmpDir, 'test2.txt');
|
||||
const filename2 = join(tmpdir.path, 'test2.txt');
|
||||
const buf = Buffer.from(s, 'utf8');
|
||||
|
||||
fs.writeFile(filename2, buf, common.mustCall(function(e) {
|
||||
|
|
@ -62,7 +63,7 @@ fs.writeFile(filename2, buf, common.mustCall(function(e) {
|
|||
}));
|
||||
|
||||
// test that writeFile accepts numbers.
|
||||
const filename3 = join(common.tmpDir, 'test3.txt');
|
||||
const filename3 = join(tmpdir.path, 'test3.txt');
|
||||
|
||||
const m = 0o600;
|
||||
fs.writeFile(filename3, n, { mode: m }, common.mustCall(function(e) {
|
||||
|
|
@ -82,7 +83,7 @@ fs.writeFile(filename3, n, { mode: m }, common.mustCall(function(e) {
|
|||
}));
|
||||
|
||||
// test that writeFile accepts file descriptors
|
||||
const filename4 = join(common.tmpDir, 'test4.txt');
|
||||
const filename4 = join(tmpdir.path, 'test4.txt');
|
||||
|
||||
fs.open(filename4, 'w+', common.mustCall(function(e, fd) {
|
||||
assert.ifError(e);
|
||||
|
|
|
|||
|
|
@ -4,8 +4,10 @@ const assert = require('assert');
|
|||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const file = path.join(common.tmpDir, 'write-autoclose-opt1.txt');
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
const file = path.join(tmpdir.path, 'write-autoclose-opt1.txt');
|
||||
tmpdir.refresh();
|
||||
let stream = fs.createWriteStream(file, { flags: 'w+', autoClose: false });
|
||||
stream.write('Test1');
|
||||
stream.end();
|
||||
|
|
|
|||
|
|
@ -20,14 +20,16 @@
|
|||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const file = path.join(common.tmpDir, 'write.txt');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
common.refreshTmpDir();
|
||||
const file = path.join(tmpdir.path, 'write.txt');
|
||||
|
||||
tmpdir.refresh();
|
||||
|
||||
const stream = fs.WriteStream(file);
|
||||
const _fs_close = fs.close;
|
||||
|
|
|
|||
|
|
@ -4,9 +4,10 @@ const common = require('../common');
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
const s = fs.createWriteStream(path.join(common.tmpDir, 'rw'));
|
||||
const s = fs.createWriteStream(path.join(tmpdir.path, 'rw'));
|
||||
|
||||
s.close(common.mustCall());
|
||||
s.close(common.mustCall());
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
'use strict';
|
||||
const common = require('../common');
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
const fixtures = require('../common/fixtures');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const stream = require('stream');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const firstEncoding = 'base64';
|
||||
const secondEncoding = 'latin1';
|
||||
|
||||
const examplePath = fixtures.path('x.txt');
|
||||
const dummyPath = path.join(common.tmpDir, 'x.txt');
|
||||
const dummyPath = path.join(tmpdir.path, 'x.txt');
|
||||
|
||||
common.refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
|
||||
const exampleReadStream = fs.createReadStream(examplePath, {
|
||||
encoding: firstEncoding
|
||||
|
|
|
|||
|
|
@ -25,17 +25,18 @@ const assert = require('assert');
|
|||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
{
|
||||
const file = path.join(common.tmpDir, 'write-end-test0.txt');
|
||||
const file = path.join(tmpdir.path, 'write-end-test0.txt');
|
||||
const stream = fs.createWriteStream(file);
|
||||
stream.end();
|
||||
stream.on('close', common.mustCall());
|
||||
}
|
||||
|
||||
{
|
||||
const file = path.join(common.tmpDir, 'write-end-test1.txt');
|
||||
const file = path.join(tmpdir.path, 'write-end-test1.txt');
|
||||
const stream = fs.createWriteStream(file);
|
||||
stream.end('a\n', 'utf8');
|
||||
stream.on('close', common.mustCall(function() {
|
||||
|
|
|
|||
|
|
@ -24,9 +24,10 @@ const common = require('../common');
|
|||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
const stream = fs.createWriteStream(`${common.tmpDir}/out`, {
|
||||
const stream = fs.createWriteStream(`${tmpdir.path}/out`, {
|
||||
highWaterMark: 10
|
||||
});
|
||||
const err = new Error('BAM');
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
'use strict';
|
||||
const common = require('../common');
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
|
@ -10,9 +10,11 @@ const numberError =
|
|||
const booleanError =
|
||||
/^TypeError: "options" must be a string or an object, got boolean instead\.$/;
|
||||
|
||||
const example = path.join(common.tmpDir, 'dummy');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
common.refreshTmpDir();
|
||||
const example = path.join(tmpdir.path, 'dummy');
|
||||
|
||||
tmpdir.refresh();
|
||||
|
||||
assert.doesNotThrow(() => {
|
||||
fs.createWriteStream(example, undefined);
|
||||
|
|
|
|||
|
|
@ -20,14 +20,16 @@
|
|||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const file = path.join(common.tmpDir, 'write.txt');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
common.refreshTmpDir();
|
||||
const file = path.join(tmpdir.path, 'write.txt');
|
||||
|
||||
tmpdir.refresh();
|
||||
|
||||
{
|
||||
const stream = fs.WriteStream(file);
|
||||
|
|
|
|||
|
|
@ -4,9 +4,10 @@ const assert = require('assert');
|
|||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
const fn = path.join(common.tmpDir, 'write-string-coerce.txt');
|
||||
const fn = path.join(tmpdir.path, 'write-string-coerce.txt');
|
||||
const data = true;
|
||||
const expected = String(data);
|
||||
|
||||
|
|
|
|||
|
|
@ -20,13 +20,14 @@
|
|||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const filename = path.join(common.tmpDir, 'write.txt');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const filename = path.join(tmpdir.path, 'write.txt');
|
||||
|
||||
common.refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
|
||||
// fs.writeSync with all parameters provided:
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,14 +24,16 @@ const common = require('../common');
|
|||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const fn = path.join(common.tmpDir, 'write.txt');
|
||||
const fn2 = path.join(common.tmpDir, 'write2.txt');
|
||||
const fn3 = path.join(common.tmpDir, 'write3.txt');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
tmpdir.refresh();
|
||||
|
||||
const fn = path.join(tmpdir.path, 'write.txt');
|
||||
const fn2 = path.join(tmpdir.path, 'write2.txt');
|
||||
const fn3 = path.join(tmpdir.path, 'write3.txt');
|
||||
const expected = 'ümlaut.';
|
||||
const constants = fs.constants;
|
||||
|
||||
common.refreshTmpDir();
|
||||
|
||||
fs.open(fn, 'w', 0o644, common.mustCall(function(err, fd) {
|
||||
assert.ifError(err);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
const http = require('http');
|
||||
const path = require('path');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
const agent = new http.Agent();
|
||||
|
||||
// default to localhost
|
||||
|
|
@ -33,7 +35,7 @@ assert.strictEqual(
|
|||
);
|
||||
|
||||
// unix socket
|
||||
const socketPath = path.join(common.tmpDir, 'foo', 'bar');
|
||||
const socketPath = path.join(tmpdir.path, 'foo', 'bar');
|
||||
assert.strictEqual(
|
||||
agent.getName({
|
||||
socketPath
|
||||
|
|
|
|||
|
|
@ -37,7 +37,9 @@ if (process.argv[2] === 'shasum') {
|
|||
const http = require('http');
|
||||
const cp = require('child_process');
|
||||
|
||||
const filename = require('path').join(common.tmpDir, 'big');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
const filename = require('path').join(tmpdir.path, 'big');
|
||||
let server;
|
||||
|
||||
function executeRequest(cb) {
|
||||
|
|
@ -59,7 +61,7 @@ function executeRequest(cb) {
|
|||
}
|
||||
|
||||
|
||||
common.refreshTmpDir();
|
||||
tmpdir.refresh();
|
||||
|
||||
const ddcmd = common.ddCommand(filename, 10240);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@ class Agent extends http.Agent {
|
|||
const server = http.createServer((req, res) => res.end());
|
||||
|
||||
const socketPath = common.PIPE;
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
server.listen(socketPath, common.mustCall(() => {
|
||||
const agent = new Agent({
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ class Agent extends http.Agent {
|
|||
}
|
||||
}
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
server.listen(common.PIPE, common.mustCall(() => {
|
||||
const req = http.get({
|
||||
|
|
|
|||
|
|
@ -34,7 +34,8 @@ const server = http.createServer(function(req, res) {
|
|||
});
|
||||
});
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
server.listen(common.PIPE, function() {
|
||||
const req = http.request({
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@ const domain = require('domain');
|
|||
|
||||
let d;
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
// first fire up a simple HTTP server
|
||||
const server = http.createServer(function(req, res) {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ const Countdown = require('../common/countdown');
|
|||
|
||||
http.globalAgent.maxSockets = 1;
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
const image = fixtures.readSync('/person.jpg');
|
||||
|
||||
|
|
@ -68,7 +69,7 @@ server.listen(0, function() {
|
|||
|
||||
http.get(opts, function(res) {
|
||||
console.error(`recv ${x}`);
|
||||
const s = fs.createWriteStream(`${common.tmpDir}/${x}.jpg`);
|
||||
const s = fs.createWriteStream(`${tmpdir.path}/${x}.jpg`);
|
||||
res.pipe(s);
|
||||
|
||||
s.on('finish', function() {
|
||||
|
|
@ -85,13 +86,13 @@ server.listen(0, function() {
|
|||
|
||||
function checkFiles() {
|
||||
// Should see 1.jpg, 2.jpg, ..., 100.jpg in tmpDir
|
||||
const files = fs.readdirSync(common.tmpDir);
|
||||
const files = fs.readdirSync(tmpdir.path);
|
||||
assert(total <= files.length);
|
||||
|
||||
for (let i = 0; i < total; i++) {
|
||||
const fn = `${i}.jpg`;
|
||||
assert.ok(files.includes(fn), `couldn't find '${fn}'`);
|
||||
const stat = fs.statSync(`${common.tmpDir}/${fn}`);
|
||||
const stat = fs.statSync(`${tmpdir.path}/${fn}`);
|
||||
assert.strictEqual(
|
||||
image.length, stat.size,
|
||||
`size doesn't match on '${fn}'. Got ${stat.size} bytes`);
|
||||
|
|
|
|||
|
|
@ -29,9 +29,10 @@ const NUMBER_OF_STREAMS = 2;
|
|||
|
||||
const countdown = new Countdown(NUMBER_OF_STREAMS, () => server.close());
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
const file = path.join(common.tmpDir, 'http-pipe-fs-test.txt');
|
||||
const file = path.join(tmpdir.path, 'http-pipe-fs-test.txt');
|
||||
|
||||
const server = http.createServer(common.mustCall(function(req, res) {
|
||||
const stream = fs.createWriteStream(file);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ const http = require('http');
|
|||
|
||||
const server = http.createServer((req, res) => res.end());
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
server.listen(common.PIPE, common.mustCall(() =>
|
||||
asyncLoop(makeKeepAliveRequest, 10, common.mustCall(() =>
|
||||
|
|
|
|||
|
|
@ -34,7 +34,8 @@ const server = http.createServer(function(req, res) {
|
|||
res.end();
|
||||
});
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
server.listen(common.PIPE, common.mustCall(function() {
|
||||
|
||||
|
|
|
|||
|
|
@ -11,9 +11,10 @@ const path = require('path');
|
|||
|
||||
// piping should work as expected with createWriteStream
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
const loc = fixtures.path('url-tests.js');
|
||||
const fn = path.join(common.tmpDir, 'http2-url-tests.js');
|
||||
const fn = path.join(tmpdir.path, 'http2-url-tests.js');
|
||||
|
||||
const server = http2.createServer();
|
||||
|
||||
|
|
|
|||
|
|
@ -12,9 +12,10 @@ const Countdown = require('../common/countdown');
|
|||
|
||||
// piping should work as expected with createWriteStream
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
const loc = fixtures.path('url-tests.js');
|
||||
const fn = path.join(common.tmpDir, 'http2-url-tests.js');
|
||||
const fn = path.join(tmpdir.path, 'http2-url-tests.js');
|
||||
|
||||
const server = http2.createServer();
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ const common = require('../common');
|
|||
if (!common.hasCrypto)
|
||||
common.skip('missing crypto');
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
const fixtures = require('../common/fixtures');
|
||||
const https = require('https');
|
||||
|
|
|
|||
|
|
@ -7,9 +7,10 @@ const fs = require('fs');
|
|||
const path = require('path');
|
||||
const SyncWriteStream = require('internal/fs').SyncWriteStream;
|
||||
|
||||
common.refreshTmpDir();
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
const filename = path.join(common.tmpDir, 'sync-write-stream.txt');
|
||||
const filename = path.join(tmpdir.path, 'sync-write-stream.txt');
|
||||
|
||||
// Verify constructing the instance with default options.
|
||||
{
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user