Files
node/test/parallel/test-fs-cp-async-socket.mjs
T
Maksim Romanov ae9c25acc5 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: https://github.com/nodejs/node/issues/66324
Assisted-by: a closed-source coding agent
Signed-off-by: Maksim Romanov <romanov.maxim.98@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66329
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
2026-09-28 20:12:21 +00:00

31 lines
840 B
JavaScript

// This tests that cp() returns an error if attempt is made to copy socket.
import * as common from '../common/index.mjs';
import assert from 'node:assert';
import { cp } from 'node:fs';
import { createServer } from 'node:net';
import { nextdir } from '../common/fs.js';
import tmpdir from '../common/tmpdir.js';
const isWindows = process.platform === 'win32';
if (isWindows) {
common.skip('No socket support on Windows');
}
// See https://github.com/nodejs/node/pull/48409
if (common.isInsideDirWithUnusualChars) {
common.skip('Test is broken in directories with unusual characters');
}
tmpdir.refresh();
{
const dest = nextdir();
const server = createServer();
server.listen(common.PIPE);
cp(common.PIPE, dest, common.mustCall((err) => {
assert.strictEqual(err.code, 'ERR_FS_CP_SOCKET');
server.close();
}));
}