From 2c02f0d1281e9c723303bce72fe2bab246d75257 Mon Sep 17 00:00:00 2001 From: Alberto Bertogli Date: Sat, 2 Sep 2023 14:12:36 +0100 Subject: [PATCH] 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. --- test/t-20-bad_configs/run.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/t-20-bad_configs/run.sh b/test/t-20-bad_configs/run.sh index a31a194..89255e1 100755 --- a/test/t-20-bad_configs/run.sh +++ b/test/t-20-bad_configs/run.sh @@ -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