From 0108ff6b51e7d46f1d4126f3a334d9bdbe31d8f4 Mon Sep 17 00:00:00 2001 From: Antoine du HAMEL Date: Wed, 27 Jun 2018 00:51:21 +0200 Subject: [PATCH] test: add support for NODE_TEST_DIR on a separate mount point Linux permits a filesystem to be mounted at multiple points, but `fs.renameSync` does not work across different mount points, even if the same filesystem is mounted on both. This fixes failing tests when NODE_TEST_DIR mount point is different from the one on which the tests are executed (E.G. on a separate partition). Ref: http://man7.org/linux/man-pages/man2/rename.2.html PR-URL: https://github.com/nodejs/node/pull/21552 Refs: http://man7.org/linux/man-pages/man2/rename.2.html Reviewed-By: James M Snell Reviewed-By: Joyee Cheung Reviewed-By: Richard Lau Reviewed-By: Ben Coe --- test/parallel/test-fs-copyfile.js | 2 +- test/parallel/test-fs-error-messages.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-fs-copyfile.js b/test/parallel/test-fs-copyfile.js index 6e5d6c9403e795..f001535598bbeb 100644 --- a/test/parallel/test-fs-copyfile.js +++ b/test/parallel/test-fs-copyfile.js @@ -64,7 +64,7 @@ try { } catch (err) { assert.strictEqual(err.syscall, 'copyfile'); assert(err.code === 'ENOTSUP' || err.code === 'ENOTTY' || - err.code === 'ENOSYS'); + err.code === 'ENOSYS' || err.code === 'EXDEV'); assert.strictEqual(err.path, src); assert.strictEqual(err.dest, dest); } diff --git a/test/parallel/test-fs-error-messages.js b/test/parallel/test-fs-error-messages.js index f406e8743ed120..8ef009e8128b0d 100644 --- a/test/parallel/test-fs-error-messages.js +++ b/test/parallel/test-fs-error-messages.js @@ -303,6 +303,11 @@ function re(literals, ...values) { `ENOTEMPTY: directory not empty, rename '${existingDir}' -> ` + `'${existingDir2}'`); assert.strictEqual(err.errno, uv.UV_ENOTEMPTY); + } else if (err.code === 'EXDEV') { // not on the same mounted filesystem + assert.strictEqual( + err.message, + `EXDEV: cross-device link not permitted, rename '${existingDir}' -> ` + + `'${existingDir2}'`); } else if (err.code === 'EEXIST') { // smartos and aix assert.strictEqual( err.message,