@@ -34,24 +34,23 @@ function actual {
3434 echo " $dir " /" $bb " .output.$ext
3535}
3636
37- function tester {
38- cmdline=" $1 "
37+ function start {
38+ echo
39+ echo " 🧪 $( tput setaf 5) Starting Pipeline Test: $( tput bold) $1 $( tput sgr0) "
40+ echo -n " $( tput dim) "
41+ }
42+
43+ function validate {
44+ echo -n " $( tput sgr0) "
45+ actual_ec=$1
3946 expected=" $2 "
4047 actual=" $3 "
4148 expected_ec=${4:- 0}
4249
43- echo " "
44- echo " ------------------------------------------------------------------------------------"
45- echo " $( tput bold) Test:$( tput sgr0) $1 "
46- echo " $( tput bold) Expected:$( tput sgr0) $expected "
47- echo " $( tput bold) Actual:$( tput sgr0) $actual "
48- echo " $( tput bold) Expected exit code$( tput sgr0) : $expected_ec "
49- echo " ------------------------------------------------------------------------------------"
50+ echo " 🧪 $( tput setaf 5) Expected: $expected $( tput sgr0) "
51+ echo " 🧪 $( tput setaf 5) Actual: $actual $( tput sgr0) "
52+ echo " 🧪 $( tput setaf 5) Expected exit code: $expected_ec $( tput sgr0) "
5053
51- set +e
52- eval " $1 $input "
53- actual_ec=$?
54- set -e
5554 if [[ $actual_ec = $expected_ec ]]
5655 then echo " ✅ PASS the exit code matches actual_ec=$actual_ec expected_ec=$expected_ec test=$1 "
5756 else echo " ❌ FAIL mismatched exit code actual_ec=$actual_ec expected_ec=$expected_ec test=$1 " && return 1
@@ -75,14 +74,28 @@ function tester {
7574}
7675
7776lpcat=" $lp cat $VERBOSE "
78- lpcatfinal=" LUNCHPAIL_FORCE_TTY=1 $lp cat $VERBOSE "
7977
80- tester " $lpcatfinal $IN1 " " $IN1 " $( actual " $IN1 " ) # input should equal output
81- tester " $lpcatfinal nopenopenopenopenope" n/a n/a 1 # expect failure trying to cat a non-existent file
78+ start " cat"
79+ $lpcat $IN1
80+ validate $? " $IN1 " $( actual " $IN1 " ) # input should equal output
81+
82+ start " cat expecting error"
83+ set +e
84+ $lpcat nopenopenopenopenope
85+ validate $? n/a n/a 1
86+ set -e
87+
88+ start " cat | cat"
89+ $lpcat $IN1 | $lpcat
90+ validate $? " $IN1 " $( actual " $IN1 " .)
8291
83- tester " $lpcat $IN1 | $lpcatfinal " " $IN1 " $( actual " $IN1 " . ) # cat | cat: input should still equal output
84- tester " $lpcat $IN1 | $lpcat | $lpcatfinal " " $IN1 " $( actual " $IN1 " . ) # cat | cat | cat: input should still equal output
85- tester " $lpcat $IN1 | $lpcat | $lpcat | $lpcatfinal " " $IN1 " $( actual " $IN1 " .) # cat | cat | cat | cat: input should still equal output
92+ start " cat | cat | cat"
93+ $lpcat $IN1 | $lpcat | $lpcat # cat | cat | cat
94+ validate $? " $IN1 " $( actual " $IN1 " .)
8695
96+ start " cat | cat | cat | cat"
97+ $lpcat $IN1 | $lpcat | $lpcat | $lpcat # cat | cat | cat | cat
98+ validate $? " $IN1 " $( actual " $IN1 " .)
8799
100+ echo
88101echo " ✅ PASS all pipeline tests have passed!"
0 commit comments