GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: move tmpdir to submodule of common · nodejs/node@a1b0d5d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • benchmark
    • http
      • http_server_for_chunky_client.js
    • module
      • module-loader.js
  • test
    • addons
      • load-long-path
        • test.js
      • symlinked-module
        • test.js
    • async-hooks
      • test-graph.pipeconnect.js
      • test-pipeconnectwrap.js
    • common
      • README.md
      • index.js
      • tmpdir.js
    • es-module
      • test-esm-preserve-symlinks.js
      • test-esm-symlink.js
    • known_issues
      • test-cwd-enoent-file.js
      • test-module-deleted-extensions.js
    • parallel
      • test-benchmark-fs.js
      • test-child-process-fork-exec-path.js
      • test-cli-node-options-disallowed.js
      • test-cli-node-options.js
      • test-cluster-eaccess.js
      • test-cluster-http-pipe.js
      • test-cluster-net-listen-relative-path.js
      • test-crypto-sign-verify.js
      • test-cwd-enoent-preload.js
      • test-cwd-enoent-repl.js
      • test-cwd-enoent.js
      • test-file-write-stream.js
      • test-file-write-stream2.js
      • test-file-write-stream3.js
      • test-fs-access.js
      • test-fs-append-file-sync.js
      • test-fs-append-file.js
      • test-fs-buffer.js
      • test-fs-buffertype-writesync.js
      • test-fs-chmod.js
      • test-fs-copyfile.js
      • test-fs-fsync.js
      • test-fs-link.js
      • test-fs-long-path.js
      • test-fs-make-callback.js
      • test-fs-mkdir-rmdir.js
      • test-fs-mkdir.js
      • test-fs-mkdtemp.js
      • test-fs-non-number-arguments-throw.js
      • test-fs-open-flags.js
      • test-fs-open-numeric-flags.js
      • test-fs-options-immutable.js
      • test-fs-promisified.js
      • test-fs-read-stream-fd.js
      • test-fs-read-stream.js
      • test-fs-readdir-ucs2.js
      • test-fs-readdir.js
      • test-fs-readfile-pipe-large.js
      • test-fs-readfile-unlink.js
      • test-fs-readfilesync-pipe-large.js
      • test-fs-realpath.js
      • test-fs-sir-writes-alot.js
      • test-fs-stream-double-close.js
      • test-fs-symlink-dir-junction-relative.js
      • test-fs-symlink-dir-junction.js
      • test-fs-symlink.js
      • test-fs-syncwritestream.js
      • test-fs-truncate-GH-6233.js
      • test-fs-truncate-fd.js
      • test-fs-truncate-sync.js
      • test-fs-truncate.js
      • test-fs-utimes.js
      • test-fs-watch-encoding.js
      • test-fs-watch-recursive.js
      • test-fs-watch.js
      • test-fs-watchfile.js
      • test-fs-write-buffer.js
      • test-fs-write-file-buffer.js
      • test-fs-write-file-invalid-path.js
      • test-fs-write-file-sync.js
      • test-fs-write-file-uint8array.js
      • test-fs-write-file.js
      • test-fs-write-stream-autoclose-option.js
      • test-fs-write-stream-change-open.js
      • test-fs-write-stream-double-close.js
      • test-fs-write-stream-encoding.js
      • test-fs-write-stream-end.js
      • test-fs-write-stream-err.js
      • test-fs-write-stream-throw-type-error.js
      • test-fs-write-stream.js
      • test-fs-write-string-coerce.js
      • test-fs-write-sync.js
      • test-fs-write.js
      • test-http-agent-getname.js
      • test-http-chunk-problem.js
      • test-http-client-abort-keep-alive-queued-unix-socket.js
      • test-http-client-abort-unix-socket.js
      • test-http-client-pipe-end.js
      • test-http-client-response-domain.js
      • test-http-get-pipeline-problem.js
      • test-http-pipe-fs.js
      • test-http-unix-socket-keep-alive.js
      • test-http-unix-socket.js
      • test-http2-compat-serverrequest-pipe.js
      • test-http2-pipe.js
      • test-https-unix-socket-self-signed.js
      • test-internal-fs-syncwritestream.js
      • test-module-circular-symlinks.js
      • test-module-loading-globalpaths.js
      • test-module-symlinked-peer-modules.js
      • test-net-connect-options-fd.js
      • test-net-connect-options-path.js
      • test-net-pingpong.js
      • test-net-pipe-connect-errors.js
      • test-net-server-listen-handle.js
      • test-net-server-listen-path.js
      • test-npm-install.js
      • test-pipe-address.js
      • test-pipe-file-to-http.js
      • test-pipe-stream.js
      • test-pipe-unref.js
      • test-pipe-writev.js
      • test-process-chdir.js
      • test-process-execpath.js
      • test-process-redirect-warnings-env.js
      • test-process-redirect-warnings.js
      • test-regress-GH-3739.js
      • test-repl-history-perm.js
      • test-repl-persistent-history.js
      • test-repl-save-load.js
      • test-repl.js
      • test-require-long-path.js
      • test-require-symlink.js
      • test-require-unicode.js
      • test-stdin-from-file.js
      • test-stdout-to-file.js
      • test-tls-connect-pipe.js
      • test-tls-net-connect-prefer-path.js
      • test-tls-wrap-econnreset-pipe.js
      • test-trace-events-all.js
      • test-trace-events-async-hooks.js
      • test-trace-events-binding.js
      • test-trace-events-category-used.js
      • test-trace-events-none.js
      • test-trace-events-process-exit.js
      • test-trace-events-v8.js
      • test-zlib-from-gzip.js
    • pummel
      • test-fs-largefile.js
      • test-fs-watch-file-slow.js
      • test-fs-watch-file.js
      • test-fs-watch-non-recursive.js
      • test-regress-GH-814.js
      • test-regress-GH-814_2.js
      • test-tls-session-timeout.js
    • sequential
      • test-async-wrap-getasyncid.js
      • test-fs-readfile-tostring-fail.js
      • test-fs-watch.js
      • test-http2-timeout-large-write-file.js
      • test-module-loading.js
      • test-regress-GH-4027.js
    • tick-processor
      • tick-processor-base.js

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎benchmark/http/http_server_for_chunky_client.js‎

Copy file name to clipboardExpand all lines: benchmark/http/http_server_for_chunky_client.js
+3-10Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,15 @@
22

33
const assert = require('assert');
44
const http = require('http');
5-
const fs = require('fs');
65
const { fork } = require('child_process');
76
const common = require('../common.js');
8-
const { PIPE, tmpDir } = require('../../test/common');
7+
const { PIPE } = require('../../test/common');
8+
const tmpdir = require('../../test/common/tmpdir');
99
process.env.PIPE_NAME = PIPE;
1010

11-
try {
12-
fs.accessSync(tmpDir, fs.F_OK);
13-
} catch (e) {
14-
fs.mkdirSync(tmpDir);
15-
}
11+
tmpdir.refresh();
1612

1713
var server;
18-
try {
19-
fs.unlinkSync(process.env.PIPE_NAME);
20-
} catch (e) { /* ignore */ }
2114

2215
server = http.createServer(function(req, res) {
2316
const headers = {
Collapse file

‎benchmark/module/module-loader.js‎

Copy file name to clipboardExpand all lines: benchmark/module/module-loader.js
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ const fs = require('fs');
33
const path = require('path');
44
const common = require('../common.js');
55

6-
const { refreshTmpDir, tmpDir } = require('../../test/common');
7-
const benchmarkDirectory = path.join(tmpDir, 'nodejs-benchmark-module');
6+
const tmpdir = require('../../test/common/tmpdir');
7+
const benchmarkDirectory = path.join(tmpdir.path, 'nodejs-benchmark-module');
88

99
const bench = common.createBenchmark(main, {
1010
thousands: [50],
@@ -15,7 +15,7 @@ const bench = common.createBenchmark(main, {
1515
function main(conf) {
1616
const n = +conf.thousands * 1e3;
1717

18-
refreshTmpDir();
18+
tmpdir.refresh();
1919
try { fs.mkdirSync(benchmarkDirectory); } catch (e) {}
2020

2121
for (var i = 0; i <= n; i++) {
@@ -35,7 +35,7 @@ function main(conf) {
3535
else
3636
measureDir(n, conf.useCache === 'true');
3737

38-
refreshTmpDir();
38+
tmpdir.refresh();
3939
}
4040

4141
function measureFull(n, useCache) {
Collapse file

‎test/addons/load-long-path/test.js‎

Copy file name to clipboardExpand all lines: test/addons/load-long-path/test.js
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ const fs = require('fs');
77
const path = require('path');
88
const assert = require('assert');
99

10-
common.refreshTmpDir();
10+
const tmpdir = require('../../common/tmpdir');
11+
tmpdir.refresh();
1112

1213
// make a path that is more than 260 chars long.
1314
// Any given folder cannot have a name longer than 260 characters,
1415
// so create 10 nested folders each with 30 character long names.
15-
let addonDestinationDir = path.resolve(common.tmpDir);
16+
let addonDestinationDir = path.resolve(tmpdir.path);
1617

1718
for (let i = 0; i < 10; i++) {
1819
addonDestinationDir = path.join(addonDestinationDir, 'x'.repeat(30));
Collapse file

‎test/addons/symlinked-module/test.js‎

Copy file name to clipboardExpand all lines: test/addons/symlinked-module/test.js
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ const assert = require('assert');
1212
// This test should pass in Node.js v4 and v5. This test will pass in Node.js
1313
// with https://github.com/nodejs/node/pull/5950 reverted.
1414

15-
common.refreshTmpDir();
15+
const tmpdir = require('../../common/tmpdir');
16+
tmpdir.refresh();
1617

1718
const addonPath = path.join(__dirname, 'build', common.buildType);
18-
const addonLink = path.join(common.tmpDir, 'addon');
19+
const addonLink = path.join(tmpdir.path, 'addon');
1920

2021
try {
2122
fs.symlinkSync(addonPath, addonLink);
Collapse file

‎test/async-hooks/test-graph.pipeconnect.js‎

Copy file name to clipboardExpand all lines: test/async-hooks/test-graph.pipeconnect.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ const verifyGraph = require('./verify-graph');
66

77
const net = require('net');
88

9-
common.refreshTmpDir();
9+
const tmpdir = require('../common/tmpdir');
10+
tmpdir.refresh();
1011

1112
const hooks = initHooks();
1213
hooks.enable();
Collapse file

‎test/async-hooks/test-pipeconnectwrap.js‎

Copy file name to clipboardExpand all lines: test/async-hooks/test-pipeconnectwrap.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ const { checkInvocations } = require('./hook-checks');
88

99
const net = require('net');
1010

11-
common.refreshTmpDir();
11+
const tmpdir = require('../common/tmpdir');
12+
tmpdir.refresh();
1213

1314
const hooks = initHooks();
1415
hooks.enable();
Collapse file

‎test/common/README.md‎

Copy file name to clipboardExpand all lines: test/common/README.md
+14-10Lines changed: 14 additions & 10 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This directory contains modules used to test the Node.js implementation.
1010
* [DNS module](#dns-module)
1111
* [Duplex pair helper](#duplex-pair-helper)
1212
* [Fixtures module](#fixtures-module)
13+
* [tmpdir module](#tmpdir-module)
1314
* [WPT module](#wpt-module)
1415

1516
## Benchmark Module
@@ -312,11 +313,6 @@ A port number for tests to use if one is needed.
312313

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

315-
### refreshTmpDir()
316-
* return [&lt;String>]
317-
318-
Deletes the testing 'tmp' directory and recreates it.
319-
320316
### restoreStderr()
321317

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

370366
Synchronous version of `spawnPwd`.
371367

372-
### tmpDir
373-
* [&lt;String>]
374-
375-
The realpath of the 'tmp' directory.
376-
377368
## Countdown Module
378369

379370
The `Countdown` module provides a simple countdown mechanism for tests that
@@ -492,6 +483,19 @@ Returns the result of
492483
Returns the result of
493484
`fs.readFileSync(path.join(fixtures.fixturesDir, 'keys', arg), 'enc')`.
494485

486+
## tmpdir Module
487+
488+
The `tmpdir` module supports the use of a temporary directory for testing.
489+
490+
### path
491+
* [&lt;String>]
492+
493+
The realpath of the testing temporary directory.
494+
495+
### refresh()
496+
497+
Deletes and recreates the testing temporary directory.
498+
495499
## WPT Module
496500

497501
The wpt.js module is a port of parts of
Collapse file

‎test/common/index.js‎

Copy file name to clipboardExpand all lines: test/common/index.js
+2-64Lines changed: 2 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,10 @@ const stream = require('stream');
3030
const util = require('util');
3131
const Timer = process.binding('timer_wrap').Timer;
3232
const { fixturesDir } = require('./fixtures');
33-
34-
const testRoot = process.env.NODE_TEST_DIR ?
35-
fs.realpathSync(process.env.NODE_TEST_DIR) : path.resolve(__dirname, '..');
33+
const tmpdir = require('./tmpdir');
3634

3735
const noop = () => {};
3836

39-
// Using a `.` prefixed name, which is the convention for "hidden" on POSIX,
40-
// gets tools to ignore it by default or by simple rules, especially eslint.
41-
let tmpDirName = '.tmp';
4237
// PORT should match the definition in test/testpy/__init__.py.
4338
exports.PORT = +process.env.NODE_COMMON_PORT || 12346;
4439
exports.isWindows = process.platform === 'win32';
@@ -121,63 +116,6 @@ if (process.env.NODE_TEST_WITH_ASYNC_HOOKS) {
121116
}).enable();
122117
}
123118

124-
function rimrafSync(p) {
125-
let st;
126-
try {
127-
st = fs.lstatSync(p);
128-
} catch (e) {
129-
if (e.code === 'ENOENT')
130-
return;
131-
}
132-
133-
try {
134-
if (st && st.isDirectory())
135-
rmdirSync(p, null);
136-
else
137-
fs.unlinkSync(p);
138-
} catch (e) {
139-
if (e.code === 'ENOENT')
140-
return;
141-
if (e.code === 'EPERM')
142-
return rmdirSync(p, e);
143-
if (e.code !== 'EISDIR')
144-
throw e;
145-
rmdirSync(p, e);
146-
}
147-
}
148-
149-
function rmdirSync(p, originalEr) {
150-
try {
151-
fs.rmdirSync(p);
152-
} catch (e) {
153-
if (e.code === 'ENOTDIR')
154-
throw originalEr;
155-
if (e.code === 'ENOTEMPTY' || e.code === 'EEXIST' || e.code === 'EPERM') {
156-
const enc = exports.isLinux ? 'buffer' : 'utf8';
157-
fs.readdirSync(p, enc).forEach((f) => {
158-
if (f instanceof Buffer) {
159-
const buf = Buffer.concat([Buffer.from(p), Buffer.from(path.sep), f]);
160-
rimrafSync(buf);
161-
} else {
162-
rimrafSync(path.join(p, f));
163-
}
164-
});
165-
fs.rmdirSync(p);
166-
}
167-
}
168-
}
169-
170-
exports.refreshTmpDir = function() {
171-
rimrafSync(exports.tmpDir);
172-
fs.mkdirSync(exports.tmpDir);
173-
};
174-
175-
if (process.env.TEST_THREAD_ID) {
176-
exports.PORT += process.env.TEST_THREAD_ID * 100;
177-
tmpDirName += `.${process.env.TEST_THREAD_ID}`;
178-
}
179-
exports.tmpDir = path.join(testRoot, tmpDirName);
180-
181119
let opensslCli = null;
182120
let inFreeBSDJail = null;
183121
let localhostIPv4 = null;
@@ -271,7 +209,7 @@ Object.defineProperty(exports, 'hasFipsCrypto', {
271209
});
272210

273211
{
274-
const localRelative = path.relative(process.cwd(), `${exports.tmpDir}/`);
212+
const localRelative = path.relative(process.cwd(), `${tmpdir.path}/`);
275213
const pipePrefix = exports.isWindows ? '\\\\.\\pipe\\' : localRelative;
276214
const pipeName = `node-test.${process.pid}.sock`;
277215
exports.PIPE = path.join(pipePrefix, pipeName);
Collapse file

‎test/common/tmpdir.js‎

Copy file name to clipboard
+67Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/* eslint-disable required-modules */
2+
'use strict';
3+
4+
const fs = require('fs');
5+
const path = require('path');
6+
7+
function rimrafSync(p) {
8+
let st;
9+
try {
10+
st = fs.lstatSync(p);
11+
} catch (e) {
12+
if (e.code === 'ENOENT')
13+
return;
14+
}
15+
16+
try {
17+
if (st && st.isDirectory())
18+
rmdirSync(p, null);
19+
else
20+
fs.unlinkSync(p);
21+
} catch (e) {
22+
if (e.code === 'ENOENT')
23+
return;
24+
if (e.code === 'EPERM')
25+
return rmdirSync(p, e);
26+
if (e.code !== 'EISDIR')
27+
throw e;
28+
rmdirSync(p, e);
29+
}
30+
}
31+
32+
function rmdirSync(p, originalEr) {
33+
try {
34+
fs.rmdirSync(p);
35+
} catch (e) {
36+
if (e.code === 'ENOTDIR')
37+
throw originalEr;
38+
if (e.code === 'ENOTEMPTY' || e.code === 'EEXIST' || e.code === 'EPERM') {
39+
const enc = process.platform === 'linux' ? 'buffer' : 'utf8';
40+
fs.readdirSync(p, enc).forEach((f) => {
41+
if (f instanceof Buffer) {
42+
const buf = Buffer.concat([Buffer.from(p), Buffer.from(path.sep), f]);
43+
rimrafSync(buf);
44+
} else {
45+
rimrafSync(path.join(p, f));
46+
}
47+
});
48+
fs.rmdirSync(p);
49+
}
50+
}
51+
}
52+
53+
const testRoot = process.env.NODE_TEST_DIR ?
54+
fs.realpathSync(process.env.NODE_TEST_DIR) : path.resolve(__dirname, '..');
55+
56+
// Using a `.` prefixed name, which is the convention for "hidden" on POSIX,
57+
// gets tools to ignore it by default or by simple rules, especially eslint.
58+
let tmpdirName = '.tmp';
59+
if (process.env.TEST_THREAD_ID) {
60+
tmpdirName += `.${process.env.TEST_THREAD_ID}`;
61+
}
62+
exports.path = path.join(testRoot, tmpdirName);
63+
64+
exports.refresh = () => {
65+
rimrafSync(exports.path);
66+
fs.mkdirSync(exports.path);
67+
};
Collapse file

‎test/es-module/test-esm-preserve-symlinks.js‎

Copy file name to clipboardExpand all lines: test/es-module/test-esm-preserve-symlinks.js
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ const assert = require('assert');
77
const path = require('path');
88
const fs = require('fs');
99

10-
common.refreshTmpDir();
11-
const tmpDir = common.tmpDir;
10+
const tmpdir = require('../common/tmpdir');
11+
tmpdir.refresh();
12+
const tmpDir = tmpdir.path;
1213

1314
const entry = path.join(tmpDir, 'entry.js');
1415
const real = path.join(tmpDir, 'real.js');

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.