Skip to content

Commit 4e4bc53

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 4e4bc53

File tree

2 files changed

+36
-19
lines changed

2 files changed

+36
-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: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,22 @@ function actual {
3434
echo "$dir"/"$bb".output.$ext
3535
}
3636

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
3945
expected="$2"
4046
actual="$3"
4147
expected_ec=${4:-0}
4248

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)"
5052

51-
set +e
52-
eval "$1 $input"
53-
actual_ec=$?
54-
set -e
5553
if [[ $actual_ec = $expected_ec ]]
5654
then echo "✅ PASS the exit code matches actual_ec=$actual_ec expected_ec=$expected_ec test=$1"
5755
else echo "❌ FAIL mismatched exit code actual_ec=$actual_ec expected_ec=$expected_ec test=$1" && return 1
@@ -75,14 +73,27 @@ function tester {
7573
}
7674

7775
lpcat="$lp cat $VERBOSE"
78-
lpcatfinal="LUNCHPAIL_FORCE_TTY=1 $lp cat $VERBOSE"
7976

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" .)
8290

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" .)
8694

95+
start "cat | cat | cat | cat"
96+
$lpcat $IN1 | $lpcat | $lpcat | $lpcat # cat | cat | cat | cat
97+
validate $? "$IN1" $(actual "$IN1" .)
8798

8899
echo "✅ PASS all pipeline tests have passed!"

0 commit comments

Comments
 (0)