mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
test_tail: add test_follow_name_truncate4
This commit is contained in:
parent
8ee806a444
commit
f3aacac9d8
1 changed files with 34 additions and 3 deletions
|
@ -3,7 +3,7 @@
|
|||
// * For the full copyright and license information, please view the LICENSE
|
||||
// * file that was distributed with this source code.
|
||||
|
||||
// spell-checker:ignore (ToDO) abcdefghijklmnopqrstuvwxyz efghijklmnopqrstuvwxyz vwxyz emptyfile logfile file siette ocho nueve diez
|
||||
// spell-checker:ignore (ToDO) abcdefghijklmnopqrstuvwxyz efghijklmnopqrstuvwxyz vwxyz emptyfile file siette ocho nueve diez
|
||||
// spell-checker:ignore (libs) kqueue
|
||||
// spell-checker:ignore (jargon) tailable untailable
|
||||
|
||||
|
@ -22,8 +22,8 @@ use std::time::Duration;
|
|||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub static BACKEND: &str = "inotify";
|
||||
#[cfg(all(unix, not(target_os = "linux")))]
|
||||
pub static BACKEND: &str = "kqueue";
|
||||
// #[cfg(all(unix, not(target_os = "linux")))]
|
||||
// pub static BACKEND: &str = "kqueue";
|
||||
|
||||
static FOOBAR_TXT: &str = "foobar.txt";
|
||||
static FOOBAR_2_TXT: &str = "foobar2.txt";
|
||||
|
@ -1709,6 +1709,37 @@ fn test_follow_name_truncate3() {
|
|||
assert!(buf_stderr.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_follow_name_truncate4() {
|
||||
// Truncating a file with the same content it already has should not trigger a truncate event
|
||||
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let at = &ts.fixtures;
|
||||
|
||||
let mut args = vec!["-s.1", "--max-unchanged-stats=1", "-F", "file"];
|
||||
|
||||
let delay = 100;
|
||||
for _ in 0..2 {
|
||||
at.append("file", "foobar\n");
|
||||
|
||||
let mut p = ts.ucmd().set_stdin(Stdio::null()).args(&args).run_no_wait();
|
||||
sleep(Duration::from_millis(100));
|
||||
|
||||
at.truncate("file", "foobar\n");
|
||||
sleep(Duration::from_millis(delay));
|
||||
|
||||
p.kill().unwrap();
|
||||
sleep(Duration::from_millis(delay));
|
||||
|
||||
let (buf_stdout, buf_stderr) = take_stdout_stderr(&mut p);
|
||||
assert!(buf_stderr.is_empty());
|
||||
assert_eq!(buf_stdout, "foobar\n");
|
||||
|
||||
at.remove("file");
|
||||
args.push("---disable-inotify");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(all(unix, not(any(target_os = "android", target_vendor = "apple"))))] // FIXME: make this work not just on Linux
|
||||
fn test_follow_name_move_create() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue