Skip to content

Commit 3b22520

Browse files
drewfishrvagg
authored andcommitted
test: fs.link() test runs on same device
When running the tests if `NODE_TEST_DIR` is set to a device different than the location of the test files (where this repo is checked out), then the parallel/test-fs-link.js test will fail with `EXDEV: cross-device link not permitted`. The code works fine (and is in fact throwing an error as desired) but the test fails. This commit first creates the "source" file in the same directory as the "destination" (where the hardlink will be created). PR-URL: #4861 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 1860eae commit 3b22520

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

test/parallel/test-fs-link.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ const fs = require('fs');
77
common.refreshTmpDir();
88

99
// test creating and reading hard link
10-
const srcPath = path.join(common.fixturesDir, 'cycles', 'root.js');
10+
const srcPath = path.join(common.tmpDir, 'hardlink-target.txt');
1111
const dstPath = path.join(common.tmpDir, 'link1.js');
12+
fs.writeFileSync(srcPath, 'hello world');
1213

1314
const callback = function(err) {
1415
if (err) throw err;
15-
const srcContent = fs.readFileSync(srcPath, 'utf8');
1616
const dstContent = fs.readFileSync(dstPath, 'utf8');
17-
assert.strictEqual(srcContent, dstContent);
17+
assert.strictEqual('hello world', dstContent);
1818
};
1919

2020
fs.link(srcPath, dstPath, common.mustCall(callback));

0 commit comments

Comments
 (0)