Skip to content

Conversation

JRF63
Copy link
Contributor

@JRF63 JRF63 commented Apr 27, 2024

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 tty
  • test_mv_sticky_to_xpart - Needs root, a username in NON_ROOT_USERNAME and must not be run together with other tests

I 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 of option_env! and std::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 in OTHER_PARTITION_TMPDIR. Haven't tested if it's possible to call diskutil or newfs from the GH macOS runner.

@JRF63 JRF63 marked this pull request as draft April 27, 2024 10:10
tree/src/mv.rs Outdated
None
} else {
eprintln!("{}: {}", target, e);
eprintln!("{}: {}", target.to_string_lossy(), e);
Copy link
Contributor

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(),
Copy link
Contributor

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));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.display() etc

@jgarzik
Copy link
Contributor

jgarzik commented Apr 27, 2024

general comment: it is preferred to create a separate commit that moves ls integrations tests to a separate sub-directory. Then, add additional commits which add mv tests and fixes. This makes both diffs more readable and test-able.

@JRF63 JRF63 force-pushed the mv-fixes branch 2 times, most recently from 1a9af94 to 16b2464 Compare May 1, 2024 17:33
Copy link
Contributor

@jgarzik jgarzik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@JRF63 JRF63 marked this pull request as ready for review May 1, 2024 18:21
@jgarzik jgarzik merged commit 2f79012 into rustcoreutils:main May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants