mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-01 05:27:45 +00:00
tests/touch: add tests for trailing slashes + -c
This commit is contained in:
parent
13e912bcbd
commit
7e1c6d1baf
1 changed files with 40 additions and 0 deletions
|
@ -701,3 +701,43 @@ fn test_touch_leap_second() {
|
|||
assert_eq!(atime.unix_seconds() - epoch.unix_seconds(), 60);
|
||||
assert_eq!(mtime.unix_seconds() - epoch.unix_seconds(), 60);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_touch_trailing_slash_no_create() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
at.touch("file");
|
||||
ucmd.args(&["-c", "file/"]).fails().code_is(1);
|
||||
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
ucmd.args(&["-c", "no-file/"]).succeeds();
|
||||
assert!(
|
||||
!at.file_exists("no-file") && !at.dir_exists("no-file") && !at.symlink_exists("no-file")
|
||||
);
|
||||
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
at.relative_symlink_file("nowhere", "dangling");
|
||||
ucmd.args(&["-c", "dangling/"]).succeeds();
|
||||
assert!(!at.file_exists("nowhere"));
|
||||
assert!(at.symlink_exists("dangling"));
|
||||
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
at.relative_symlink_file("loop", "loop");
|
||||
ucmd.args(&["-c", "loop/"]).fails().code_is(1);
|
||||
assert!(!at.file_exists("loop"));
|
||||
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
at.touch("file2");
|
||||
at.relative_symlink_file("file2", "link1");
|
||||
ucmd.args(&["-c", "link1/"]).fails().code_is(1);
|
||||
assert!(at.file_exists("file2"));
|
||||
assert!(at.symlink_exists("link1"));
|
||||
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
at.mkdir("dir");
|
||||
ucmd.args(&["-c", "dir/"]).succeeds();
|
||||
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
at.mkdir("dir2");
|
||||
at.relative_symlink_dir("dir2", "link2");
|
||||
ucmd.args(&["-c", "link2/"]).succeeds();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue