diff --git a/tests/fixtures/tail/foobar2.txt b/tests/fixtures/tail/foobar2.txt new file mode 100644 index 000000000..25973d326 --- /dev/null +++ b/tests/fixtures/tail/foobar2.txt @@ -0,0 +1,2 @@ +un +deux diff --git a/tests/fixtures/tail/foobar_follow_multiple.expected b/tests/fixtures/tail/foobar_follow_multiple.expected new file mode 100644 index 000000000..140a9088d --- /dev/null +++ b/tests/fixtures/tail/foobar_follow_multiple.expected @@ -0,0 +1,15 @@ +==> foobar.txt <== +dos +tres +quattro +cinco +seis +siette +ocho +nueve +diez +once + +==> foobar2.txt <== +un +deux diff --git a/tests/fixtures/tail/foobar_follow_multiple_appended.expected b/tests/fixtures/tail/foobar_follow_multiple_appended.expected new file mode 100644 index 000000000..0896d3743 --- /dev/null +++ b/tests/fixtures/tail/foobar_follow_multiple_appended.expected @@ -0,0 +1,4 @@ + +==> foobar.txt <== +doce +trece diff --git a/tests/test_tail.rs b/tests/test_tail.rs index fbd527b39..c842354d1 100644 --- a/tests/test_tail.rs +++ b/tests/test_tail.rs @@ -8,6 +8,7 @@ use uu_tail::parse_size; static UTIL_NAME: &'static str = "tail"; static FOOBAR_TXT: &'static str = "foobar.txt"; +static FOOBAR_2_TXT: &'static str = "foobar2.txt"; static FOOBAR_WITH_NULL_TXT: &'static str = "foobar_with_null.txt"; #[test] @@ -56,6 +57,26 @@ fn test_follow() { child.kill().unwrap(); } +#[test] +fn test_follow_multiple() { + let (at, mut ucmd) = testing(UTIL_NAME); + let mut child = ucmd.arg("-f").arg(FOOBAR_TXT).arg(FOOBAR_2_TXT).run_no_wait(); + + let expected = at.read("foobar_follow_multiple.expected"); + assert_eq!(read_size(&mut child, expected.len()), expected); + + let first_append = "trois\n"; + at.append(FOOBAR_2_TXT, first_append); + assert_eq!(read_size(&mut child, first_append.len()), first_append); + + let second_append = "doce\ntrece\n"; + let expected = at.read("foobar_follow_multiple_appended.expected"); + at.append(FOOBAR_TXT, second_append); + assert_eq!(read_size(&mut child, expected.len()), expected); + + child.kill().unwrap(); +} + #[test] fn test_single_big_args() { const FILE: &'static str = "single_big_args.txt";