1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

install: remove / from end of path if it exists so as not to mess with .exists() (#5730)

* remove / from end of path if it exists so as not to mess with .exists()

* install: fix / removal from path

* Fix clippy warnings

* Add test for install target ends with /
This commit is contained in:
Matei Mantu 2023-12-27 14:37:17 +02:00 committed by GitHub
parent 413638c789
commit bf26eda786
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 0 deletions

View file

@ -1589,3 +1589,27 @@ fn test_t_exist_dir() {
.fails()
.stderr_contains("failed to access 'sub4/file_exists': Not a directory");
}
#[test]
fn test_target_file_ends_with_slash() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
let source = "source_file";
let target_dir = "dir";
let target_file = "dir/target_file";
let target_file_slash = format!("{}/", target_file);
at.touch(source);
at.mkdir(target_dir);
at.touch(target_file);
scene
.ucmd()
.arg("-t")
.arg(target_file_slash)
.arg("-D")
.arg(source)
.fails()
.stderr_contains("failed to access 'dir/target_file/': Not a directory");
}