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 rvagg committed Feb 28, 2019
1 parent 9a093c0 commit 6a80380
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 @@ -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
);
}
Expand Down

0 comments on commit 6a80380

Please sign in to comment.