Browse Source

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: https://github.com/nodejs/node/pull/4861
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Rich Trott <rtrott@gmail.com>
v5.x
Drew Folta 9 years ago
committed by Rod Vagg
parent
commit
3b225209f0
  1. 6
      test/parallel/test-fs-link.js

6
test/parallel/test-fs-link.js

@ -7,14 +7,14 @@ const fs = require('fs');
common.refreshTmpDir();
// test creating and reading hard link
const srcPath = path.join(common.fixturesDir, 'cycles', 'root.js');
const srcPath = path.join(common.tmpDir, 'hardlink-target.txt');
const dstPath = path.join(common.tmpDir, 'link1.js');
fs.writeFileSync(srcPath, 'hello world');
const callback = function(err) {
if (err) throw err;
const srcContent = fs.readFileSync(srcPath, 'utf8');
const dstContent = fs.readFileSync(dstPath, 'utf8');
assert.strictEqual(srcContent, dstContent);
assert.strictEqual('hello world', dstContent);
};
fs.link(srcPath, dstPath, common.mustCall(callback));

Loading…
Cancel
Save