tail: test following multiple files

The test_follow_multiple() test verifies that input is read upon append
on both files and that headers are printed when expected.
This commit is contained in:
Mariano Casco 2016-05-30 17:34:53 -03:00
parent f9627e02d0
commit 9c584bab9d
4 changed files with 42 additions and 0 deletions

2
tests/fixtures/tail/foobar2.txt vendored Normal file
View file

@ -0,0 +1,2 @@
un
deux

View file

@ -0,0 +1,15 @@
==> foobar.txt <==
dos
tres
quattro
cinco
seis
siette
ocho
nueve
diez
once
==> foobar2.txt <==
un
deux

View file

@ -0,0 +1,4 @@
==> foobar.txt <==
doce
trece

View file

@ -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";