1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00

test: Make t-20-bad_configs less flaky due to asynchronous logging

The t-20-bad_configs test can sometimes have false positives because
the last line recorded in the log isn't always the one causing the
failure, due to asynchronous logging and in particular in combination
with coverage tests (which alter the os.Exit behaviour subtly).

This patch fixes that by having the tests look at the last 4 lines of
output instead. This is not super pretty, but it should be good enough
to cover for any timing issues that arise in these particular tests.
This commit is contained in:
Alberto Bertogli
2023-09-02 14:12:36 +01:00
parent 888b2df4c1
commit 2c02f0d128

View File

@@ -33,13 +33,15 @@ for i in c-*; do
fi
# Test that they failed as expected, and not by chance/unrelated error.
if ! tail -n 1 ".chasquid-$i.out" \
# Look in the last 4 lines, because the fatal error may not be in the
# very last one due to asynchronous logging.
if ! tail -n 4 ".chasquid-$i.out" \
| grep -q -E "$(cat "$i/.expected-error")"; then
echo "$i failed"
echo "expected last line to match:"
echo "expected last 4 lines to contain:"
echo " '$(cat "$i/.expected-error")'"
echo "got last line:"
echo " '$(tail -n 1 ".chasquid-$i.out")'"
echo "got last 4 lines:"
tail -n 4 ".chasquid-$i.out" | sed -e 's/^/ /g'
echo
fail "$i: chasquid did not fail as expected"
fi