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 <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ben Coe <bencoe@gmail.com>
This commit is contained in:
Antoine du HAMEL 2018-06-27 00:51:21 +02:00 committed by Rich Trott
parent 43cc6bc9f3
commit b75bde3bc5
2 changed files with 6 additions and 1 deletions

View File

@ -64,7 +64,7 @@ try {
} catch (err) { } catch (err) {
assert.strictEqual(err.syscall, 'copyfile'); assert.strictEqual(err.syscall, 'copyfile');
assert(err.code === 'ENOTSUP' || err.code === 'ENOTTY' || assert(err.code === 'ENOTSUP' || err.code === 'ENOTTY' ||
err.code === 'ENOSYS'); err.code === 'ENOSYS' || err.code === 'EXDEV');
assert.strictEqual(err.path, src); assert.strictEqual(err.path, src);
assert.strictEqual(err.dest, dest); assert.strictEqual(err.dest, dest);
} }

View File

@ -303,6 +303,11 @@ function re(literals, ...values) {
`ENOTEMPTY: directory not empty, rename '${existingDir}' -> ` + `ENOTEMPTY: directory not empty, rename '${existingDir}' -> ` +
`'${existingDir2}'`); `'${existingDir2}'`);
assert.strictEqual(err.errno, uv.UV_ENOTEMPTY); 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 } else if (err.code === 'EEXIST') { // smartos and aix
assert.strictEqual( assert.strictEqual(
err.message, err.message,