Skip to content

Commit

Permalink
test: use tmpdir.resolve()
Browse files Browse the repository at this point in the history
Subsystems: blob, child_process, common, crypto, http, http2,
readline, repl, snapshot, trace_events

PR-URL: #49127
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
  • Loading branch information
LiviaMedeiros authored and RafaelGSS committed Aug 17, 2023
1 parent 661b055 commit 6595367
Show file tree
Hide file tree
Showing 60 changed files with 92 additions and 154 deletions.
7 changes: 3 additions & 4 deletions test/parallel/test-blob-file-backed.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ const {
const {
unlink
} = require('fs/promises');
const path = require('path');
const { Blob } = require('buffer');

const tmpdir = require('../common/tmpdir');
const testfile = path.join(tmpdir.path, 'test-file-backed-blob.txt');
const testfile2 = path.join(tmpdir.path, 'test-file-backed-blob2.txt');
const testfile3 = path.join(tmpdir.path, 'test-file-backed-blob3.txt');
const testfile = tmpdir.resolve('test-file-backed-blob.txt');
const testfile2 = tmpdir.resolve('test-file-backed-blob2.txt');
const testfile3 = tmpdir.resolve('test-file-backed-blob3.txt');
tmpdir.refresh();

const data = `${'a'.repeat(1000)}${'b'.repeat(2000)}`;
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-child-process-fork-exec-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ const common = require('../common');
const tmpdir = require('../common/tmpdir');
const { addLibraryPath } = require('../common/shared-lib-util');
const assert = require('assert');
const path = require('path');
const fs = require('fs');
const { fork } = require('child_process');

const msg = { test: 'this' };
const nodePath = process.execPath;
const copyPath = path.join(tmpdir.path, 'node-copy.exe');
const copyPath = tmpdir.resolve('node-copy.exe');

addLibraryPath(process.env);

Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-child-process-pipe-dataflow.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const path = require('path');
const fs = require('fs');
const spawn = require('child_process').spawn;
const tmpdir = require('../common/tmpdir');
Expand All @@ -18,7 +17,7 @@ const MB = KB * KB;

{
tmpdir.refresh();
const file = path.resolve(tmpdir.path, 'data.txt');
const file = tmpdir.resolve('data.txt');
const buf = Buffer.alloc(MB).fill('x');

// Most OS commands that deal with data, attach special meanings to new line -
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-crypto-authenticated-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ if (!common.hasCrypto)
const assert = require('assert');
const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
const stream = require('stream');
const tmpdir = require('../common/tmpdir');

Expand Down Expand Up @@ -72,7 +71,7 @@ function mstream(config) {

function fstream(config) {
const count = fstream.count++;
const filename = (name) => path.join(tmpdir.path, `${name}${count}`);
const filename = (name) => tmpdir.resolve(`${name}${count}`);

const { cipher, key, iv, aad, authTagLength, plaintextLength } = config;
const expected = Buffer.alloc(plaintextLength);
Expand Down
5 changes: 2 additions & 3 deletions test/parallel/test-crypto-sign-verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ if (!common.hasCrypto)

const assert = require('assert');
const fs = require('fs');
const path = require('path');
const exec = require('child_process').exec;
const crypto = require('crypto');
const fixtures = require('../common/fixtures');
Expand Down Expand Up @@ -617,9 +616,9 @@ assert.throws(
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();

const sigfile = path.join(tmpdir.path, 's5.sig');
const sigfile = tmpdir.resolve('s5.sig');
fs.writeFileSync(sigfile, s5);
const msgfile = path.join(tmpdir.path, 's5.msg');
const msgfile = tmpdir.resolve('s5.msg');
fs.writeFileSync(msgfile, msg);

const cmd =
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-http-agent-getname.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
require('../common');
const assert = require('assert');
const http = require('http');
const path = require('path');

const tmpdir = require('../common/tmpdir');

Expand Down Expand Up @@ -41,7 +40,7 @@ assert.strictEqual(
);

// unix socket
const socketPath = path.join(tmpdir.path, 'foo', 'bar');
const socketPath = tmpdir.resolve('foo', 'bar');
assert.strictEqual(
agent.getName({
socketPath
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http-chunk-problem.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const cp = require('child_process');

const tmpdir = require('../common/tmpdir');

const filename = require('path').join(tmpdir.path, 'big');
const filename = tmpdir.resolve('big');
let server;

function executeRequest(cb) {
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-http-pipe-fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
const common = require('../common');
const http = require('http');
const fs = require('fs');
const path = require('path');
const Countdown = require('../common/countdown');
const NUMBER_OF_STREAMS = 2;

Expand All @@ -32,7 +31,7 @@ const countdown = new Countdown(NUMBER_OF_STREAMS, () => server.close());
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();

const file = path.join(tmpdir.path, 'http-pipe-fs-test.txt');
const file = tmpdir.resolve('http-pipe-fs-test.txt');

const server = http.createServer(common.mustCall(function(req, res) {
const stream = fs.createWriteStream(file);
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-http2-compat-serverrequest-pipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ const fixtures = require('../common/fixtures');
const assert = require('assert');
const http2 = require('http2');
const fs = require('fs');
const path = require('path');

// Piping should work as expected with createWriteStream

const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const loc = fixtures.path('person-large.jpg');
const fn = path.join(tmpdir.path, 'http2-url-tests.js');
const fn = tmpdir.resolve('http2-url-tests.js');

const server = http2.createServer();

Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-http2-pipe-named-pipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ const assert = require('assert');
const http2 = require('http2');
const fs = require('fs');
const net = require('net');
const path = require('path');

// HTTP/2 servers can listen on a named pipe.

const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const loc = fixtures.path('person-large.jpg');
const fn = path.join(tmpdir.path, 'person-large.jpg');
const fn = tmpdir.resolve('person-large.jpg');

const server = http2.createServer();

Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-http2-pipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ const fixtures = require('../common/fixtures');
const assert = require('assert');
const http2 = require('http2');
const fs = require('fs');
const path = require('path');

// Piping should work as expected with createWriteStream

const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const loc = fixtures.path('person-large.jpg');
const fn = path.join(tmpdir.path, 'http2-url-tests.js');
const fn = tmpdir.resolve('http2-url-tests.js');

const server = http2.createServer();

Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-http2-respond-file-error-pipe-offset.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ if (!common.hasCrypto)
if (common.isWindows)
common.skip('no mkfifo on Windows');
const child_process = require('child_process');
const path = require('path');
const fs = require('fs');
const http2 = require('http2');
const assert = require('assert');

const tmpdir = require('../common/tmpdir');
tmpdir.refresh();

const pipeName = path.join(tmpdir.path, 'pipe');
const pipeName = tmpdir.resolve('pipe');

const mkfifo = child_process.spawnSync('mkfifo', [ pipeName ]);
if (mkfifo.error && mkfifo.error.code === 'ENOENT') {
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-http2-respond-file-with-pipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ if (!common.hasCrypto)
if (common.isWindows)
common.skip('no mkfifo on Windows');
const child_process = require('child_process');
const path = require('path');
const fs = require('fs');
const http2 = require('http2');
const assert = require('assert');

const tmpdir = require('../common/tmpdir');
tmpdir.refresh();

const pipeName = path.join(tmpdir.path, 'pipe');
const pipeName = tmpdir.resolve('pipe');

const mkfifo = child_process.spawnSync('mkfifo', [ pipeName ]);
if (mkfifo.error && mkfifo.error.code === 'ENOENT') {
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-readline-async-iterators-destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
const common = require('../common');
const fs = require('fs');
const { once } = require('events');
const { join } = require('path');
const readline = require('readline');
const assert = require('assert');

const tmpdir = require('../common/tmpdir');
tmpdir.refresh();

const filename = join(tmpdir.path, 'test.txt');
const filename = tmpdir.resolve('test.txt');

const testContents = [
'',
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-readline-async-iterators.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

const common = require('../common');
const fs = require('fs');
const { join } = require('path');
const readline = require('readline');
const { Readable } = require('stream');
const assert = require('assert');

const tmpdir = require('../common/tmpdir');
tmpdir.refresh();

const filename = join(tmpdir.path, 'test.txt');
const filename = tmpdir.resolve('test.txt');

const testContents = [
'',
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-repl-autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const stream = require('stream');
const REPL = require('internal/repl');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const { inspect } = require('util');

common.skipIfDumbTerminal();
Expand All @@ -17,7 +16,7 @@ tmpdir.refresh();

process.throwDeprecation = true;

const defaultHistoryPath = path.join(tmpdir.path, '.node_repl_history');
const defaultHistoryPath = tmpdir.resolve('.node_repl_history');

// Create an input stream specialized for testing an array of actions
class ActionStream extends stream.Stream {
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-repl-history-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const stream = require('stream');
const REPL = require('internal/repl');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const { inspect } = require('util');

common.skipIfDumbTerminal();
Expand All @@ -18,7 +17,7 @@ tmpdir.refresh();
process.throwDeprecation = true;
process.on('warning', common.mustNotCall());

const defaultHistoryPath = path.join(tmpdir.path, '.node_repl_history');
const defaultHistoryPath = tmpdir.resolve('.node_repl_history');

// Create an input stream specialized for testing an array of actions
class ActionStream extends stream.Stream {
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-repl-history-perm.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ if (common.isWindows) {
}

const assert = require('assert');
const path = require('path');
const fs = require('fs');
const repl = require('internal/repl');
const Duplex = require('stream').Duplex;
Expand All @@ -33,7 +32,7 @@ stream.readable = stream.writable = true;

const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const replHistoryPath = path.join(tmpdir.path, '.node_repl_history');
const replHistoryPath = tmpdir.resolve('.node_repl_history');

const checkResults = common.mustSucceed((r) => {
const stat = fs.statSync(replHistoryPath);
Expand Down
8 changes: 3 additions & 5 deletions test/parallel/test-repl-persistent-history.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const stream = require('stream');
const REPL = require('internal/repl');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const os = require('os');
const util = require('util');

Expand Down Expand Up @@ -60,12 +59,11 @@ const CLEAR = { ctrl: true, name: 'u' };

// File paths
const historyFixturePath = fixtures.path('.node_repl_history');
const historyPath = path.join(tmpdir.path, '.fixture_copy_repl_history');
const historyPath = tmpdir.resolve('.fixture_copy_repl_history');
const historyPathFail = fixtures.path('nonexistent_folder', 'filename');
const defaultHistoryPath = path.join(tmpdir.path, '.node_repl_history');
const defaultHistoryPath = tmpdir.resolve('.node_repl_history');
const emptyHiddenHistoryPath = fixtures.path('.empty-hidden-repl-history-file');
const devNullHistoryPath = path.join(tmpdir.path,
'.dev-null-repl-history-file');
const devNullHistoryPath = tmpdir.resolve('.dev-null-repl-history-file');
// Common message bits
const prompt = '> ';
const replDisabled = '\nPersistent history support disabled. Set the ' +
Expand Down
8 changes: 3 additions & 5 deletions test/parallel/test-repl-programmatic-history.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const stream = require('stream');
const REPL = require('repl');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const os = require('os');
const util = require('util');

Expand Down Expand Up @@ -58,12 +57,11 @@ const CLEAR = { ctrl: true, name: 'u' };

// File paths
const historyFixturePath = fixtures.path('.node_repl_history');
const historyPath = path.join(tmpdir.path, '.fixture_copy_repl_history');
const historyPath = tmpdir.resolve('.fixture_copy_repl_history');
const historyPathFail = fixtures.path('nonexistent_folder', 'filename');
const defaultHistoryPath = path.join(tmpdir.path, '.node_repl_history');
const defaultHistoryPath = tmpdir.resolve('.node_repl_history');
const emptyHiddenHistoryPath = fixtures.path('.empty-hidden-repl-history-file');
const devNullHistoryPath = path.join(tmpdir.path,
'.dev-null-repl-history-file');
const devNullHistoryPath = tmpdir.resolve('.dev-null-repl-history-file');
// Common message bits
const prompt = '> ';
const replDisabled = '\nPersistent history support disabled. Set the ' +
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-repl-require-after-write.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ const common = require('../common');
const tmpdir = require('../common/tmpdir');
const assert = require('assert');
const spawn = require('child_process').spawn;
const path = require('path');

tmpdir.refresh();

const requirePath = JSON.stringify(path.join(tmpdir.path, 'non-existent.json'));
const requirePath = JSON.stringify(tmpdir.resolve('non-existent.json'));

// Use -i to force node into interactive mode, despite stdout not being a TTY
const child = spawn(process.execPath, ['-i']);
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-repl-reverse-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const stream = require('stream');
const REPL = require('internal/repl');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const { inspect } = require('util');

common.skipIfDumbTerminal();
Expand All @@ -16,7 +15,7 @@ common.allowGlobals('aaaa');
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();

const defaultHistoryPath = path.join(tmpdir.path, '.node_repl_history');
const defaultHistoryPath = tmpdir.resolve('.node_repl_history');

// Create an input stream specialized for testing an array of actions
class ActionStream extends stream.Stream {
Expand Down
Loading

0 comments on commit 6595367

Please sign in to comment.