Skip to content

Commit f12de45

Browse files
committed
test: remove FORCE_TTY from pipelines.sh
This works around a lack of TTY in github actions. See actions/runner#241 (comment) Signed-off-by: Nick Mitchell <[email protected]>
1 parent 985fa7a commit f12de45

File tree

2 files changed

+38
-19
lines changed

2 files changed

+38
-19
lines changed

.github/workflows/tests.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ concurrency:
55
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
66
cancel-in-progress: true
77

8+
defaults:
9+
run:
10+
# GitHub Actions run without a TTY device. This is a workaround to get one,
11+
# based on https://github.com/actions/runner/issues/241#issuecomment-2019042651
12+
shell: 'script --return --quiet --log-out /dev/null --command "bash -e {0}"'
13+
814
on:
915
push:
1016
branches: [ main ]

tests/bin/pipelines.sh

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -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

7776
lpcat="$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
88101
echo "✅ PASS all pipeline tests have passed!"

0 commit comments

Comments
 (0)