Skip to content

Commit 886fd32

Browse files
maksim-romanovaduh95
authored andcommitted
test: use common.PIPE in fs.cp socket tests
The socket was created under a nested tmpdir using an absolute path, which can exceed the 104-byte sun_path limit on macOS when the checkout lives in a long directory. common.PIPE uses a path relative to the cwd, as the other pipe tests do. Fixes: #66324 Assisted-by: a closed-source coding agent Signed-off-by: Maksim Romanov <romanov.maxim.98@gmail.com> PR-URL: #66329 Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
1 parent 3c50781 commit 886fd32

2 files changed

Lines changed: 6 additions & 14 deletions

File tree

‎test/parallel/test-fs-cp-async-socket.mjs‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
import * as common from '../common/index.mjs';
44
import assert from 'node:assert';
5-
import { cp, mkdirSync } from 'node:fs';
5+
import { cp } from 'node:fs';
66
import { createServer } from 'node:net';
7-
import { join } from 'node:path';
87
import { nextdir } from '../common/fs.js';
98
import tmpdir from '../common/tmpdir.js';
109

@@ -21,13 +20,10 @@ if (common.isInsideDirWithUnusualChars) {
2120
tmpdir.refresh();
2221

2322
{
24-
const src = nextdir();
25-
mkdirSync(src);
2623
const dest = nextdir();
27-
const sock = join(src, `${process.pid}.sock`);
2824
const server = createServer();
29-
server.listen(sock);
30-
cp(sock, dest, common.mustCall((err) => {
25+
server.listen(common.PIPE);
26+
cp(common.PIPE, dest, common.mustCall((err) => {
3127
assert.strictEqual(err.code, 'ERR_FS_CP_SOCKET');
3228
server.close();
3329
}));

‎test/parallel/test-fs-cp-sync-copy-socket-error.mjs‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
import * as common from '../common/index.mjs';
33
import { nextdir } from '../common/fs.js';
44
import assert from 'node:assert';
5-
import { cpSync, mkdirSync } from 'node:fs';
5+
import { cpSync } from 'node:fs';
66
import { createServer } from 'node:net';
7-
import { join } from 'node:path';
87
import tmpdir from '../common/tmpdir.js';
98

109
const isWindows = process.platform === 'win32';
@@ -20,14 +19,11 @@ if (common.isInsideDirWithUnusualChars) {
2019
tmpdir.refresh();
2120

2221
{
23-
const src = nextdir();
24-
mkdirSync(src);
2522
const dest = nextdir();
26-
const sock = join(src, `${process.pid}.sock`);
2723
const server = createServer();
28-
server.listen(sock);
24+
server.listen(common.PIPE);
2925
assert.throws(
30-
() => cpSync(sock, dest),
26+
() => cpSync(common.PIPE, dest),
3127
{ code: 'ERR_FS_CP_SOCKET' }
3228
);
3329
server.close();

0 commit comments

Comments
 (0)