From 85e948753b50fb204ac7985f20f17f9f009a6557 Mon Sep 17 00:00:00 2001 From: Drew Folta Date: Wed, 28 Nov 2018 12:55:36 -0800 Subject: [PATCH] test: validate fs.rename() when NODE_TEST_DIR on separate mount When testing fs.rename() of an non-existent file, use a destination path which is in the same directory. Otherwise we might trigger an `EXDEV` error if NODE_TEST_DIR is a separate device than the current working directory. Fixes: https://github.com/nodejs/node/issues/21669 PR-URL: https://github.com/nodejs/node/pull/24707 Reviewed-By: Rich Trott Reviewed-By: Richard Lau Reviewed-By: Luigi Pinca --- test/parallel/test-fs-error-messages.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-fs-error-messages.js b/test/parallel/test-fs-error-messages.js index 5e7c1ec1a4553a..6c3865d3a9598f 100644 --- a/test/parallel/test-fs-error-messages.js +++ b/test/parallel/test-fs-error-messages.js @@ -289,10 +289,11 @@ function re(literals, ...values) { return true; }; - fs.rename(nonexistentFile, 'foo', common.mustCall(validateError)); + const destFile = path.join(tmpdir.path, 'foo'); + fs.rename(nonexistentFile, destFile, common.mustCall(validateError)); assert.throws( - () => fs.renameSync(nonexistentFile, 'foo'), + () => fs.renameSync(nonexistentFile, destFile), validateError ); }