Skip to content

Commit aa059c9

Browse files
committed
tests: added test for checking -n0 in follow mode
1 parent 9a0397e commit aa059c9

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/by-util/test_tail.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,28 @@ fn test_nc_0_wo_follow2() {
230230
.no_output();
231231
}
232232

233+
#[test]
234+
#[cfg(not(target_os = "windows"))]
235+
fn test_n0_with_follow() {
236+
let (at, mut ucmd) = at_and_ucmd!();
237+
let test_file = "test.txt";
238+
// Create file with multiple lines
239+
at.write(test_file, "line1\nline2\nline3\n");
240+
241+
let mut child = ucmd.arg("-n0").arg("-f").arg(test_file).run_no_wait();
242+
child.make_assertion_with_delay(500).is_alive();
243+
244+
// Append a new line
245+
at.append(test_file, "new\n");
246+
247+
// Should only print the newly appended line
248+
child
249+
.make_assertion_with_delay(DEFAULT_SLEEP_INTERVAL_MILLIS)
250+
.with_current_output()
251+
.stdout_only("new\n");
252+
child.kill();
253+
}
254+
233255
// TODO: Add similar test for windows
234256
#[test]
235257
#[cfg(unix)]

0 commit comments

Comments
 (0)