Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
b353cf3
benchmark: fix punycode test for --without-intl
TimothyGu Oct 17, 2017
218b8fd
fs: fix `createReadStream(…, {end: n})` for non-seekable fds
addaleax Mar 13, 2018
986fd40
util: escaping object keys in util.inspect()
zheyz Nov 13, 2017
f0f7c2b
http: free the parser before emitting 'upgrade'
lpinca Jan 17, 2018
f068918
stream: remove unreachable code
lpinca Jan 18, 2018
9a56ad9
test: use correct size in test-stream-buffer-list
lpinca Jan 18, 2018
b665068
stream: simplify `src._readableState` to `state`
Jan 20, 2018
325dc27
doc: capitalize non-primitive types
vsemozhetbyt Jan 12, 2018
ddb42b5
doc: warn about GCM authenticity
tniessen Jan 25, 2018
9f02f29
doc: fix manpage warnings
silverwind Jan 29, 2018
c28a64a
doc: reorder section on updating PR branch
ofrobots Jan 24, 2018
67f9df9
url: simplify loop in parser
tniessen Jan 30, 2018
06c1ef7
doc: add Gibson Fahnestock to TSC
Trott Jan 31, 2018
de63954
test: fix flaky test-http-dns-error
bengl Oct 26, 2017
06a28aa
src: free memory before re-setting URLHost value
prog1dev Jan 23, 2018
4f1939b
tools: auto fix custom eslint rule
shobhitchittora Oct 31, 2017
9b0d337
doc: improve stream documentation
Jan 25, 2018
02eab11
test: speed up parallel/test-tls-session-cache
addaleax Jan 29, 2018
9f158ac
lib: remove debugger dead code
liqyan Jan 22, 2018
f4ccb9d
deps: update node-inspect to 1.11.3
Jan 24, 2018
cad0bbb
async_hooks: clean up comments
ofrobots Jan 30, 2018
b8d3c40
doc: move Brian White to TSC Emeriti list
Trott Jan 31, 2018
091ab5b
v8: add missing ',' in OpenBSD's 'sources' section.
qbit Jan 30, 2018
d594a68
build: add cflags for OpenBSD, remove stray comma.
qbit Jan 30, 2018
e6d6042
doc: streamline README intro
Trott Jan 31, 2018
5e86f20
string_decoder: reset decoder on end
jridgewell Feb 1, 2018
c570180
test: add test for tls benchmarks
apapirovski Feb 1, 2018
6ef1fa3
test: verify the shell option works properly on execFile
jvelezpo Jan 25, 2018
21441e8
win, build: fix intl-none option
poiru Jan 22, 2018
07f9147
doc: improve http.request documentation
Zarel Jan 8, 2018
0a5b0d5
doc: shell option for the execFile and execFileSync functions
jvelezpo Jan 18, 2018
89c1bf3
build: allow x86_64 as a dest_cpu alias for x64
rvagg Jan 9, 2018
2a18de3
test: remove destructor from node_test_fixture
danbev Feb 2, 2018
af3e5f2
net: remove redundant code from _writeGeneric()
lpinca Jan 29, 2018
433be0d
tools: add check for using process.binding crypto
danbev Dec 26, 2017
a3111ba
build: refine static and shared lib build
yhwang Dec 5, 2017
5590088
errors: remove ERR_OUTOFMEMORY
tniessen Dec 27, 2017
059a803
test: fix spelling in test case comments
tniessen Jan 6, 2018
63b0de2
lib: fix spelling in comments
tniessen Jan 6, 2018
790ef2f
test: update references to archived repository
tniessen Dec 31, 2017
8c25003
readline: update references to archived repository
tniessen Dec 31, 2017
f687bb1
test: move tmpdir to submodule of common
Trott Dec 25, 2017
9f380dc
tools: add .mjs linting for Windows
vsemozhetbyt Feb 4, 2018
88e0f23
test: add assertions for TextEncoder/Decoder
Jan 13, 2018
d503427
doc: linkify missing types
vsemozhetbyt Jan 29, 2018
bc66f08
deps: V8: backport 596d55a from upstream
MylesBorins Sep 18, 2017
44cb0d3
crypto: reuse variable instead of reevaluation
tniessen Dec 18, 2017
6ba7fd0
tools: non-Ascii linter for /lib only
Jan 8, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: move tmpdir to submodule of common
Move tmpdir functionality to its own module (common/tmpdir).

Backport-PR-URL: #19488
PR-URL: #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>
  • Loading branch information
Trott authored and MylesBorins committed Mar 28, 2018
commit f687bb1005d70144d5a4607bd98ef840ea82d35f
13 changes: 3 additions & 10 deletions benchmark/http/http_server_for_chunky_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
8 changes: 4 additions & 4 deletions benchmark/module/module-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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++) {
Expand All @@ -35,7 +35,7 @@ function main(conf) {
else
measureDir(n, conf.useCache === 'true');

refreshTmpDir();
tmpdir.refresh();
}

function measureFull(n, useCache) {
Expand Down
5 changes: 3 additions & 2 deletions test/addons/load-long-path/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
5 changes: 3 additions & 2 deletions test/addons/symlinked-module/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion test/async-hooks/test-graph.pipeconnect.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion test/async-hooks/test-pipeconnectwrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
24 changes: 14 additions & 10 deletions test/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -312,11 +313,6 @@ A port number for tests to use if one is needed.

Logs '1..0 # Skipped: ' + `msg`

### refreshTmpDir()
* return [&lt;String>]

Deletes the testing 'tmp' directory and recreates it.

### restoreStderr()

Restore the original `process.stderr.write`. Used to restore `stderr` to its
Expand Down Expand Up @@ -369,11 +365,6 @@ Platform normalizes the `pwd` command.

Synchronous version of `spawnPwd`.

### tmpDir
* [&lt;String>]

The realpath of the 'tmp' directory.

## Countdown Module

The `Countdown` module provides a simple countdown mechanism for tests that
Expand Down Expand Up @@ -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
* [&lt;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
Expand Down
66 changes: 2 additions & 64 deletions test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
67 changes: 67 additions & 0 deletions test/common/tmpdir.js
Original file line number Diff line number Diff line change
@@ -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);
};
5 changes: 3 additions & 2 deletions test/es-module/test-esm-preserve-symlinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
5 changes: 3 additions & 2 deletions test/es-module/test-esm-symlink.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
5 changes: 3 additions & 2 deletions test/known_issues/test-cwd-enoent-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions test/known_issues/test-module-deleted-extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ 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'];
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'));
7 changes: 4 additions & 3 deletions test/parallel/test-benchmark-fs.js
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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 });
Loading