From 31583de34bb82a0fa8ce0e6f53e6bcf0d28e9c60 Mon Sep 17 00:00:00 2001 From: Drew Folta Date: Mon, 25 Jan 2016 11:08:30 -0800 Subject: [PATCH 1/2] 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 copies the "source" file to the same directory as the "destination" (where the hardlink will be created). --- test/parallel/test-fs-link.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-fs-link.js b/test/parallel/test-fs-link.js index acbedc1452231d..848550293c17c8 100644 --- a/test/parallel/test-fs-link.js +++ b/test/parallel/test-fs-link.js @@ -8,15 +8,19 @@ common.refreshTmpDir(); // test creating and reading hard link const srcPath = path.join(common.fixturesDir, 'cycles', 'root.js'); +const srcContent = fs.readFileSync(srcPath, 'utf8'); +const tmpSrcPath = path.join(common.tmpDir, 'root.js'); const dstPath = path.join(common.tmpDir, 'link1.js'); const callback = function(err) { if (err) throw err; - const srcContent = fs.readFileSync(srcPath, 'utf8'); const dstContent = fs.readFileSync(dstPath, 'utf8'); assert.strictEqual(srcContent, dstContent); }; +// copy source file to same directory to avoid cross-filesystem issues +fs.writeFileSync(tmpSrcPath, srcContent, 'utf8'); + fs.link(srcPath, dstPath, common.mustCall(callback)); // test error outputs From f90c991749f452c7147e7128182abbc2443f745f Mon Sep 17 00:00:00 2001 From: Drew Folta Date: Mon, 25 Jan 2016 12:59:15 -0800 Subject: [PATCH 2/2] fixup test: fs.link() test runs on same device --- test/parallel/test-fs-link.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/test/parallel/test-fs-link.js b/test/parallel/test-fs-link.js index 848550293c17c8..292d48fb53e5c6 100644 --- a/test/parallel/test-fs-link.js +++ b/test/parallel/test-fs-link.js @@ -7,20 +7,16 @@ const fs = require('fs'); common.refreshTmpDir(); // test creating and reading hard link -const srcPath = path.join(common.fixturesDir, 'cycles', 'root.js'); -const srcContent = fs.readFileSync(srcPath, 'utf8'); -const tmpSrcPath = path.join(common.tmpDir, '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 dstContent = fs.readFileSync(dstPath, 'utf8'); - assert.strictEqual(srcContent, dstContent); + assert.strictEqual('hello world', dstContent); }; -// copy source file to same directory to avoid cross-filesystem issues -fs.writeFileSync(tmpSrcPath, srcContent, 'utf8'); - fs.link(srcPath, dstPath, common.mustCall(callback)); // test error outputs