Conversation
Changes made based on comments from pull request nix-rust#1058
|
@asomers I am a little uncertain as to the github way to amend a pull request. Instead of amending and doing a force push I instead followed some fairly old instructions here https://stackoverflow.com/questions/9790448/how-to-update-a-pull-request-from-forked-repo and pushed the patch. I am able to see this second commit. I assume this is all part of the same original pull request but please advise if there is more that I should do to have this latest patch reviewed. Thanks. |
|
The easiest way is to amend and/or rebase your changes locally, and then do a force push, like this: |
jlb6740
left a comment
There was a problem hiding this comment.
Previous concerns are hopefully addressed here but let me know if there are more comments.
|
@asomers .. Ok. I was afraid that would erase comment history asking for the update but I wasn't sure and also I wasn't sure if it mattered to the project. The update ce88edd is here but I don't see a way to ask for a new pull request so I assume you can see and are notified of it? Let me know if you need me to somehow resubmit. Thanks. |
|
|
||
|
|
||
| #[test] | ||
| #[should_panic] |
There was a problem hiding this comment.
You should the expected("whatever") string to should_panic to ensure that it's only catching the desired panic, and no others.
There was a problem hiding this comment.
Hi ... Thanks for the tip. Update #3 includes this change.
|
|
||
| // Attempt unlink dir at relative path without proper flag | ||
| unlinkat(Some(dirfd), dirname, UnlinkatFlags::NoRemoveDir).unwrap(); | ||
| assert!(dirpath.exists()); |
There was a problem hiding this comment.
This line is dead code, assuming the line above panics.
There was a problem hiding this comment.
Thanks. You are right. Not sure why I left this in but it is now removed.
| - Add `forkpty` | ||
| ([#1042](https://github.com/nix-rust/nix/pull/1042)) | ||
| - Add `unlinkat` | ||
| ([#TBD](https://github.com/nix-rust/nix/pull/TBD)) |
There was a problem hiding this comment.
Don't forget to replace the TBD.
ce88edd to
dd9fdd5
Compare
Changes made based on comments from pull request nix-rust#1058
| let dirfd = fcntl::open(tempdir.path(), fcntl::OFlag::empty(), stat::Mode::empty()).unwrap(); | ||
|
|
||
| // Attempt unlink dir at relative path without proper flag | ||
| unlinkat(Some(dirfd), dirname, UnlinkatFlags::NoRemoveDir).unwrap(); |
There was a problem hiding this comment.
You don't need should_panic for this. Just replace the unwrap with an unwrap_err and check the result.
|
@asomers I tried to be more specific by matching on the error message, but there is a discrepancy in the error returned by i686-appledarwin and x86_64-apple-darwin "Sys(EPERM)", and every other target being tested Sys(EISDIR) https://travis-ci.org/nix-rust/nix/builds/541975264?utm_source=github_status&utm_medium=notification. I will resubmit and have to be a less specific about the type of error expected. Not sure if this indicates a bug on those apple targets or not? |
asomers
left a comment
There was a problem hiding this comment.
This is not a case of Apple being wrong, this is a case of POSIX being stupid. EPERM is the error that POSIX says should be returned in this case. But it looks like both FreeBSD And Linux choose to return EISDIR instead, which makes more sense. I suggest that your test should accept either error.
https://pubs.opengroup.org/onlinepubs/9699919799/functions/unlink.html
|
I see. Expecting either is the better option but it's not clear to me the expect way to account for this when assigning a string to expected for the match. Any pointer?
|
|
It's easy if you do as I suggested earlier and use |
I used should_panic and expected based on your suggests. I am just revisiting this patch today and didn't even notice that latest comment ... I went right to understanding the failure that precedes it. I'll change to using un_wrap error, but I'd like some learnings here. Is this only being suggested now because we realize we want to match against multiple potential error messages or should I have avoided should_panic from the beginning? In general when do you suggest using should_panic? I noticed a few other tests in this folder that use the syntax, but not many have elected to. |
|
It's true. When you first posted this PR, I didn't see the forest for the trees. The
|
|
@asomers Ok, thanks. So to recap from the two bullets .. the first is saying generally prefer using should_panic, while the second bullet is saying but when it it's possible to just compare the error directly then to do that? It still seems a little ambigious considering I thought the point of "expected" was to compare the error message though in this specific case it is not as helpful since we'd like to accept multiple error values. If those apple targets had returned EISDIR the same as FreeBSD and Linux (or they all returned EPERM) I am still unsure what would be the preferred way to check the error? In any case I made an update here: https://gist.github.com/jlb6740/9848944cbab4a1ab5165a3f5ee2b3e1f. If it looks ok, I'll push this and update the CHANGELOG as well. Thanks. |
|
The reason why this test shouldn't use |
Ok ... Thanks. I think I see your point. I'll go ahead and resubmit. Any more suggestion just let me know. Thanks for your patients. |
d45da51 to
8d7467e
Compare
Changes made based on comments from pull request nix-rust#1058
|
@asomers Github is showing me a "Changes requested" message but I think the previous requests have been addressed. Clicking "resolve conversations" doesn't seem to get rid of the message .. not sure what github wants from me to make the message go away. If there is anything else you see amiss just let me know. My latest update seemed ok, but I did need a rebase in order to pass all tests. |
|
Hi @asomers, Was there anything left here you'd like updated? I think commit 4 should have resolved the remaining requests? |
| ([#1042](https://github.com/nix-rust/nix/pull/1042)) | ||
| - Add `sched_yield` | ||
| ([#1050](https://github.com/nix-rust/nix/pull/1050)) | ||
| - Add `unlinkat` |
There was a problem hiding this comment.
Your changelog entry got dislocated during a rebase.
There was a problem hiding this comment.
Hi ... what do you mean by dislocated? For the latest patch this is the change I intended for changelog.md:
- ([#TBD](https://github.com/nix-rust/nix/pull/1058))
+ ([#1058](https://github.com/nix-rust/nix/pull/1058))
Is this what you can see? Is there another push needed for this file?
| // Attempt unlink dir at relative path without proper flag | ||
| let err_result = unlinkat(Some(dirfd), dirname, UnlinkatFlags::NoRemoveDir).unwrap_err(); | ||
| match err_result { | ||
| Error::Sys(Errno::EISDIR) => println!("{}", err_result), |
There was a problem hiding this comment.
passing tests shouldn't print anything. Just do assert!(err_result == Error::Sys(Errno::EISDIR) || err_result == Error::Sys(Errno::EPERM))
There was a problem hiding this comment.
I see .. good catch/comment. I've corrected this in the 5th commit.
|
@asomers I've made changes to test/test_unistd.rs .. but maybe didn't address CHANGELOG.md comment? Let me know. Thanks. |
|
The changelog entry is in the section for release 0.14. It should be in the unreleased section. |
Ahh .. I see. I've moved it to the "Added" part of the "Unreleased" section. Thanks. |
asomers
left a comment
There was a problem hiding this comment.
Just remove the extra newlines and squash your commits, then I think we can merge this.
| assert!(!filepath.exists()); | ||
| } | ||
|
|
||
|
|
There was a problem hiding this comment.
Hi @asomers .. Done. Last commit should address this.
|
There are conflicts now that you must resolve. |
cfa7003 to
6f86db1
Compare
Changes made based on comments from pull request nix-rust#1058
6f86db1 to
bcb557b
Compare
Changes made based on comments from pull request nix-rust#1058
|
I've rebased and pushed ... Looks like the latest push is passing all tests. |
|
You still haven't squashed your commits, though. |
Ok ... I am familiar with the best way to push and merge patches to gerrit but obviously I am still new to github. I was thinking my commits would be squashed automatically when you merged here. Is the work flow to squash on my local branch and then push here (i.e. git rebase -i HEAD~7), or does github provide some UI for this. I am seeing this: https://help.github.com/en/articles/about-pull-request-merges#squash-and-merge-your-pull-request-commits but I can't find this button or tell if it is for me or the person doing the merging? |
|
Many projects squash commits when they merge the PR. However, Nix uses the bors merge bot, so that isn't possible for us. Instead, you must squash yourself. |
This adds the unlinkat function, which is part of POSIX: http://pubs.opengroup.org/onlinepubs/9699919799/functions/unlinkat.html and widely implmented on Unix-family platforms. Implement unlinkat - Update comments to unlink at and breakup tests Changes made based on comments from pull request nix-rust#1058 Implement unlinkat - Update should_panic for more precise check Updae should_panic attribute for more precise check. Also remove some dead code and note the pull request ID. Implement unlinkat - Update error handling to use unwrap_err The previous patch failed testing on two targets that returned EPERM as the Sys error instead of EISDIR. This patch changes from using the should_panic attribute to using the unwrap_err and matching against the result. Implement Unlinkat - Passing tests should not print anything. Fix. Implement unlinkat - Update location of commit comment in the CHANGELOG Implement unlinkat - Remove newline
You respond quick .. thanks. Ok. So do a git rebase -i and then do a force push. I'll give that a try. |
bcb557b to
273fb63
Compare
|
@asmoers Hi .. Not sure how bors works or if anything else is needed on my end for the pull request. Let me know. I'll be starting another api, mimicking what's been done here. |
1058: Implement unlinkat r=asomers a=jlb6740 This adds the unlinkat function, which is part of POSIX: http://pubs.opengroup.org/onlinepubs/9699919799/functions/unlinkat.html and widely implmented on Unix-family platforms. Co-authored-by: Johnnie Birch <45402135+jlb6740@users.noreply.github.com>
Build succeeded
|
This adds the unlinkat function, which is part of POSIX: http://pubs.opengroup.org/onlinepubs/9699919799/functions/unlinkat.html and widely implmented on Unix-family platforms. Implement unlinkat - Update comments to unlink at and breakup tests Changes made based on comments from pull request nix-rust#1058 Implement unlinkat - Update should_panic for more precise check Updae should_panic attribute for more precise check. Also remove some dead code and note the pull request ID. Implement unlinkat - Update error handling to use unwrap_err The previous patch failed testing on two targets that returned EPERM as the Sys error instead of EISDIR. This patch changes from using the should_panic attribute to using the unwrap_err and matching against the result. Implement Unlinkat - Passing tests should not print anything. Fix. Implement unlinkat - Update location of commit comment in the CHANGELOG Implement unlinkat - Remove newline
This adds the unlinkat function, which is part of POSIX:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/unlinkat.html
and widely implmented on Unix-family platforms.