skip/test.sh

64 lines
1.1 KiB
Bash
Raw Normal View History

2022-01-01 15:49:17 +00:00
#!/usr/bin/env bash
set -e
echo "> skip a line when reading from stdin"
INPUT=$(cat<<EOF
line 1
line 2
EOF
)
echo "line 2" > test.expect
2022-01-01 16:00:09 +00:00
echo "$INPUT" | ./skip 1 > test.out
2022-01-01 15:49:17 +00:00
diff --brief test.expect test.out
echo "> skip a line when reading from a file"
cat<<EOF > test.in
line 1
line 2
EOF
echo "line 2" > test.expect
2022-01-01 16:00:09 +00:00
./skip 1 test.in > test.out
2022-01-01 15:49:17 +00:00
diff --brief test.expect test.out
echo "> skip until 2 matching lines seen"
cat<<EOF > test.in
alpha
beta
alpha
2022-01-01 16:19:44 +00:00
alpha
2022-01-01 15:49:17 +00:00
gamma
2022-01-01 16:19:44 +00:00
alpha
EOF
cat<<EOF > test.expect
alpha
gamma
alpha
2022-01-01 15:49:17 +00:00
EOF
2022-01-01 16:00:09 +00:00
./skip 2 test.in --line alpha > test.out
2022-01-01 15:49:17 +00:00
diff --brief test.expect test.out
echo "> skip lines until 2 tokens seen"
cat<<EOF > test.in
Lorem ipsum dolor sit amet,
consectetur adipiscing elit,
sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua.
Ut enim ad minim veniam,
quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea
commodo consequat.
EOF
cat<<EOF > test.expect
Ut enim ad minim veniam,
quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea
commodo consequat.
EOF
2022-01-01 16:00:09 +00:00
./skip 2 test.in --token dolor > test.out
2022-01-01 15:49:17 +00:00
diff --brief test.expect test.out
rm test.in test.out test.expect
echo done