@@ -34,24 +34,22 @@ function actual {
34
34
echo " $dir " /" $bb " .output.$ext
35
35
}
36
36
37
- function tester {
38
- cmdline=" $1 "
37
+ function start {
38
+ echo " 🧪 $( tput setaf 5) Starting Pipeline Test: $( tput bold) $1 $( tput sgr0) "
39
+ echo -n " $( tput dim) "
40
+ }
41
+
42
+ function validate {
43
+ echo " $( tput sgr0) "
44
+ actual_ec=$1
39
45
expected=" $2 "
40
46
actual=" $3 "
41
47
expected_ec=${4:- 0}
42
48
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 " ------------------------------------------------------------------------------------"
49
+ echo " 🧪 $( tput setaf 5) Expected: $expected $( tput sgr0) "
50
+ echo " 🧪 $( tput setaf 5) Actual: $actual $( tput sgr0) "
51
+ echo " 🧪 $( tput setaf 5) Expected exit code: $expected_ec $( tput sgr0) "
50
52
51
- set +e
52
- eval " $1 $input "
53
- actual_ec=$?
54
- set -e
55
53
if [[ $actual_ec = $expected_ec ]]
56
54
then echo " ✅ PASS the exit code matches actual_ec=$actual_ec expected_ec=$expected_ec test=$1 "
57
55
else echo " ❌ FAIL mismatched exit code actual_ec=$actual_ec expected_ec=$expected_ec test=$1 " && return 1
@@ -75,14 +73,27 @@ function tester {
75
73
}
76
74
77
75
lpcat=" $lp cat $VERBOSE "
78
- lpcatfinal=" LUNCHPAIL_FORCE_TTY=1 $lp cat $VERBOSE "
79
76
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
77
+ start " cat"
78
+ $lpcat $IN1
79
+ validate $? " $IN1 " $( actual " $IN1 " ) # input should equal output
80
+
81
+ start " cat expecting error"
82
+ set +e
83
+ $lpcat nopenopenopenopenope
84
+ validate $? n/a n/a 1
85
+ set -e
86
+
87
+ start " cat | cat"
88
+ $lpcat $IN1 | $lpcat
89
+ validate $? " $IN1 " $( actual " $IN1 " .)
82
90
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
91
+ start " cat | cat | cat"
92
+ $lpcat $IN1 | $lpcat | $lpcat # cat | cat | cat
93
+ validate $? " $IN1 " $( actual " $IN1 " .)
86
94
95
+ start " cat | cat | cat | cat"
96
+ $lpcat $IN1 | $lpcat | $lpcat | $lpcat # cat | cat | cat | cat
97
+ validate $? " $IN1 " $( actual " $IN1 " .)
87
98
88
99
echo " ✅ PASS all pipeline tests have passed!"
0 commit comments