Skip to content

Commit

Permalink
test: fs.link() test runs on same device
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
drewfish authored and rvagg committed Jan 27, 2016
1 parent c7af9e7 commit 7beda00
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test/parallel/test-fs-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));

0 comments on commit 7beda00

Please sign in to comment.