-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: fix todos #20319
test: fix todos #20319
Conversation
This adds a test for invalid input and solves a TODO by doing so.
I just had a closer look how to fix the error messages in e.g., Patchdiff --cc src/node_file.cc
index 89c53afc5b,89c53afc5b..f81433e53c
--- a/src/node_file.cc
+++ b/src/node_file.cc
@@@ -612,7 -612,7 +612,7 @@@ template <typename Func, typename... Ar
inline FSReqBase* AsyncDestCall(Environment* env,
FSReqBase* req_wrap,
const FunctionCallbackInfo<Value>& args,
-- const char* syscall, const char* dest, size_t len,
++ const char* syscall, const char* path, const char* dest, size_t len,
enum encoding enc, uv_fs_cb after, Func fn, Args... fn_args) {
CHECK_NE(req_wrap, nullptr);
req_wrap->Init(syscall, dest, len, enc);
@@@ -621,7 -621,7 +621,7 @@@
if (err < 0) {
uv_fs_t* uv_req = req_wrap->req();
uv_req->result = err;
-- uv_req->path = nullptr;
++ uv_req->path = path;
after(uv_req); // after may delete req_wrap if there is an error
req_wrap = nullptr;
} else {
@@@ -639,7 -639,7 +639,7 @@@ inline FSReqBase* AsyncCall(Environment
const char* syscall, enum encoding enc,
uv_fs_cb after, Func fn, Args... fn_args) {
return AsyncDestCall(env, req_wrap, args,
-- syscall, nullptr, 0, enc,
++ syscall, nullptr, nullptr, 0, enc,
after, fn, fn_args...);
}
@@@ -916,8 -916,8 +916,9 @@@ static void Symlink(const FunctionCallb
FSReqBase* req_wrap_async = GetReqWrap(env, args[3]);
if (req_wrap_async != nullptr) { // symlink(target, path, flags, req)
-- AsyncDestCall(env, req_wrap_async, args, "symlink", *path, path.length(),
-- UTF8, AfterNoArgs, uv_fs_symlink, *target, *path, flags);
++ AsyncDestCall(env, req_wrap_async, args, "symlink", *target, *path,
++ path.length(), UTF8, AfterNoArgs, uv_fs_symlink,
++ *target, *path, flags);
} else { // symlink(target, path, flags, undefinec, ctx)
CHECK_EQ(argc, 5);
FSReqWrapSync req_wrap_sync;
@@@ -942,8 -942,8 +943,9 @@@ static void Link(const FunctionCallback
FSReqBase* req_wrap_async = GetReqWrap(env, args[2]);
if (req_wrap_async != nullptr) { // link(src, dest, req)
-- AsyncDestCall(env, req_wrap_async, args, "link", *dest, dest.length(), UTF8,
-- AfterNoArgs, uv_fs_link, *src, *dest);
++ AsyncDestCall(env, req_wrap_async, args, "link", *src, *dest,
++ dest.length(), UTF8, AfterNoArgs, uv_fs_link,
++ *src, *dest);
} else { // link(src, dest)
CHECK_EQ(argc, 4);
FSReqWrapSync req_wrap_sync;
@@@ -1009,7 -1009,7 +1011,7 @@@ static void Rename(const FunctionCallba
FSReqBase* req_wrap_async = GetReqWrap(env, args[2]);
if (req_wrap_async != nullptr) {
-- AsyncDestCall(env, req_wrap_async, args, "rename", *new_path,
++ AsyncDestCall(env, req_wrap_async, args, "rename", *old_path, *new_path,
new_path.length(), UTF8, AfterNoArgs, uv_fs_rename,
*old_path, *new_path);
} else {
@@@ -1370,7 -1370,7 +1372,7 @@@ static void CopyFile(const FunctionCall
FSReqBase* req_wrap_async = GetReqWrap(env, args[3]);
if (req_wrap_async != nullptr) { // copyFile(src, dest, flags, req)
-- AsyncDestCall(env, req_wrap_async, args, "copyfile",
++ AsyncDestCall(env, req_wrap_async, args, "copyfile", *src,
*dest, dest.length(), UTF8, AfterNoArgs,
uv_fs_copyfile, *src, *dest, flags);
} else { // copyFile(src, dest, flags, undefined, ctx) Sadly, this aborts with the error: It does return the source in the message in this case, but right afterwards it crashes. |
This removes outdated TODOs and adds a test for invalid input in `fs.copyFile` and solves a TODO by doing so. PR-URL: nodejs#20319 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Landed in 541d219 |
This removes outdated TODOs and adds a test for invalid input in `fs.copyFile` and solves a TODO by doing so. PR-URL: #20319 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
See commit messages.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes