Skip to content

Commit f9f3dc9

Browse files
jasnellRafaelGSS
authored andcommitted
test: add known issue test for fs.cpSync dereference bug
Refs: #58939 PR-URL: #58941 Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent a2b72c2 commit f9f3dc9

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
'use strict';
2+
3+
// Refs: https://github.com/nodejs/node/issues/58939
4+
//
5+
// The cpSync function is not correctly handling the `dereference` option.
6+
// In this test, both the cp and cpSync functions are attempting to copy
7+
// a file over a symlinked directory. In the cp case it works fine. In the
8+
// cpSync case it fails with an error.
9+
10+
const common = require('../common');
11+
12+
const {
13+
cp,
14+
cpSync,
15+
mkdirSync,
16+
symlinkSync,
17+
writeFileSync,
18+
} = require('fs');
19+
20+
const {
21+
join,
22+
} = require('path');
23+
24+
const tmpdir = require('../common/tmpdir');
25+
tmpdir.refresh();
26+
27+
const pathA = join(tmpdir.path, 'a');
28+
const pathB = join(tmpdir.path, 'b');
29+
const pathC = join(tmpdir.path, 'c');
30+
const pathD = join(tmpdir.path, 'd');
31+
32+
writeFileSync(pathA, 'file a');
33+
mkdirSync(pathB);
34+
symlinkSync(pathB, pathC, 'dir');
35+
symlinkSync(pathB, pathD, 'dir');
36+
37+
cp(pathA, pathD, { dereference: false }, common.mustSucceed());
38+
39+
cpSync(pathA, pathC, { dereference: false });

0 commit comments

Comments
 (0)