diff options
author | Rich Trott <rtrott@gmail.com> | 2015-10-16 21:07:21 -0700 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2015-10-20 09:20:21 -0700 |
commit | 1c5784511895bbc416a5d1ae8a1e22d9dbf612ec (patch) | |
tree | 6320a567de56ef6a5dfab2e34fc359401ecec18d /test/parallel/test-fs-link.js | |
parent | 753509f5796b014acd8c58c4ce4bffde62921fa1 (diff) | |
download | android-node-v8-1c5784511895bbc416a5d1ae8a1e22d9dbf612ec.tar.gz android-node-v8-1c5784511895bbc416a5d1ae8a1e22d9dbf612ec.tar.bz2 android-node-v8-1c5784511895bbc416a5d1ae8a1e22d9dbf612ec.zip |
test: fix flaky test for symlinks
If the symlink portion of the test was being skipped due to a
combination of OS support and user privileges, then an assertion would
always fail. This fixes that problem, improves assertion error reporting
and splits the test to make it clear that it is a test for links and
symlinks.
Fixes: https://github.com/nodejs/node/issues/3311
PR-URL: https://github.com/nodejs/node/pull/3418
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Diffstat (limited to 'test/parallel/test-fs-link.js')
-rw-r--r-- | test/parallel/test-fs-link.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/parallel/test-fs-link.js b/test/parallel/test-fs-link.js new file mode 100644 index 0000000000..4e95d20f7b --- /dev/null +++ b/test/parallel/test-fs-link.js @@ -0,0 +1,20 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); +const fs = require('fs'); + +common.refreshTmpDir(); + +// test creating and reading hard link +const srcPath = path.join(common.fixturesDir, 'cycles', '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); +}; + +fs.link(srcPath, dstPath, common.mustCall(callback)); |