Skip to content
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

Closed
wants to merge 5 commits into from
Closed

test: fix todos #20319

wants to merge 5 commits into from

Conversation

BridgeAR
Copy link
Member

@BridgeAR BridgeAR commented Apr 26, 2018

See commit messages.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

This adds a test for invalid input and solves a TODO by doing so.
@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Apr 26, 2018
@BridgeAR
Copy link
Member Author

@BridgeAR BridgeAR added the wip Issues and PRs that are still a work in progress. label Apr 26, 2018
@BridgeAR
Copy link
Member Author

I just had a closer look how to fix the error messages in e.g., fs.copyFile and I came up with the following patch:

Patch
diff --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: *** Error in out/Release/node': free(): invalid pointer: 0x00007fff6dbdfe78 ***`. If someone could point out what I am doing wrong, that would be nice :-)

It does return the source in the message in this case, but right afterwards it crashes.

@BridgeAR
Copy link
Member Author

@BridgeAR BridgeAR added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. and removed wip Issues and PRs that are still a work in progress. labels Apr 26, 2018
BridgeAR added a commit to BridgeAR/node that referenced this pull request Apr 29, 2018
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>
@BridgeAR
Copy link
Member Author

Landed in 541d219

@BridgeAR BridgeAR closed this Apr 29, 2018
MylesBorins pushed a commit that referenced this pull request May 4, 2018
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>
@MylesBorins MylesBorins mentioned this pull request May 8, 2018
@BridgeAR BridgeAR deleted the fix-todos branch January 20, 2020 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants