-
Notifications
You must be signed in to change notification settings - Fork 28
mv
fixes and tests
#78
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
tree/src/mv.rs
Outdated
// 1. If the destination path exists, conditionally prompt user | ||
let target_md = match fs::metadata(target) { | ||
Ok(md) => Some(md), | ||
Err(e) => { | ||
if e.kind() == io::ErrorKind::NotFound { | ||
None | ||
} else { | ||
eprintln!("{}: {}", target, e); | ||
eprintln!("{}: {}", target.to_string_lossy(), e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer to standardize on .display()
for outputting Path and PathBuf: https://doc.rust-lang.org/std/path/struct.Path.html#method.display
tree/src/mv.rs
Outdated
let is_affirm = prompt_user(&format!("{}: {}", target, gettext("overwrite?"))); | ||
let is_affirm = prompt_user(&format!( | ||
"{}: {}", | ||
target.to_string_lossy(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer .display()
tree/src/mv.rs
Outdated
} | ||
(false, true) => { | ||
let err_str = "cannot overwrite directory with non-directory"; | ||
eprintln!("{}: {}", target.to_string_lossy(), gettext(err_str)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.display() etc
general comment: it is preferred to create a separate commit that moves |
1a9af94
to
16b2464
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This pretty much has max compatibility with GNU coreutils mv even down to the error messages.
There's 3 tests locked under the
posixutils_test_all
feature flag:test_mv_hardlink_case
- Needs a case-insensitive filesystem that can support hard links. It's hard to do it dynamically so it must be supplied through an env var,CASE_INSENSITIVE_TMPDIR
test_mv_i_link_no
- This requires script to fake ttytest_mv_sticky_to_xpart
- Needs root, a username inNON_ROOT_USERNAME
and must not be run together with other testsI experimented enabling the
posixutils_test_all
feature dynamically based on an environment variable using a build script like in this method but it seems to mess-up with incremental linking and forces a recompile everytime. It's possible that it was due to the usage ofoption_env!
andstd::env::var
might not have the same problems.The tests requiring
/dev/shm
can be made to work in macOS if a directory in another filesystem is supplied inOTHER_PARTITION_TMPDIR
. Haven't tested if it's possible to calldiskutil
ornewfs
from the GH macOS runner.