Skip to content

Commit

Permalink
test: validate fs.rename() when NODE_TEST_DIR on separate mount
Browse files Browse the repository at this point in the history
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: #21669

PR-URL: #24707
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
drewfish authored and Trott committed Nov 28, 2018
1 parent 64cea5a commit 8344f24
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/parallel/test-fs-error-messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,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
);
}
Expand Down

0 comments on commit 8344f24

Please sign in to comment.