Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/uu/install/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ pub fn uu_app() -> Command {
.about(get_message("install-about"))
.override_usage(format_usage(&get_message("install-usage")))
.infer_long_args(true)
.args_override_self(true)
.arg(backup_control::arguments::backup())
.arg(backup_control::arguments::backup_no_args())
.arg(
Expand Down
74 changes: 74 additions & 0 deletions tests/by-util/test_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,80 @@ fn test_install_nested_paths_copy_file() {
assert!(at.file_exists(format!("{dir2}/{file1}")));
}

#[test]
fn test_multiple_mode_arguments_override_not_error() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
let dir = "source_dir";

let file = "source_file";
let gid = getegid();
let uid = geteuid();

at.touch(file);
at.mkdir(dir);

scene
.ucmd()
.args(&[
file,
&format!("{dir}/{file}"),
"--owner=invalid_owner",
"--owner",
&uid.to_string(),
])
.succeeds()
.no_stderr();

scene
.ucmd()
.args(&[
file,
&format!("{dir}/{file}"),
"-o invalid_owner",
"-o",
&uid.to_string(),
])
.succeeds()
.no_stderr();

scene
.ucmd()
.args(&[file, &format!("{dir}/{file}"), "--mode=999", "--mode=200"])
.succeeds()
.no_stderr();
Comment on lines +487 to +491
Copy link
Contributor

Choose a reason for hiding this comment

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

currently testing that the command continues to succeed when overridden with duplicate argument flags, might be good to test that the override is also the last one passed through?

e.g. when you test the mode (-m) maybe you can assert that the mode is what it should be?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm so sorry; github decided not to notify me of your comment and I've only now found it.
I'll submit a PR to do that later today.


scene
.ucmd()
.args(&[file, &format!("{dir}/{file}"), "-m 999", "-m 200"])
.succeeds()
.no_stderr();

scene
.ucmd()
.args(&[
file,
&format!("{dir}/{file}"),
"--group=invalid_group",
"--group",
&gid.to_string(),
])
.succeeds()
.no_stderr();

scene
.ucmd()
.args(&[
file,
&format!("{dir}/{file}"),
"-g invalid_group",
"-g",
&gid.to_string(),
])
.succeeds()
.no_stderr();
}

#[test]
fn test_install_failing_omitting_directory() {
let scene = TestScenario::new(util_name!());
Expand Down
Loading