Skip to content

Commit

Permalink
Print logs only once even if fail is called multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
ChillerDragon committed Jan 21, 2024
1 parent de5a403 commit 8b74e29
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions integration_test/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,24 +124,28 @@ trap cleanup EXIT

function fail() {
local msg="$1"
# the first tail get swalloed
# idk why so tail twice to ensure
# getting output
# this is a bit ugly but it works
# maybe a sleep does as well
# or I still did not get flushing
tail "$ruby_logfile" &>/dev/null
if [[ "$testname" =~ ^client/ ]]
if [ ! -f "$tmpdir/fail.txt" ]
then
echo "[-] end of ruby client log:"
tail "$ruby_logfile"
echo "[-] end of server log:"
tail "$logdir/server.txt"
else
echo "[-] end of ruby server log:"
tail "$ruby_logfile"
echo "[-] end of client log:"
tail "$logdir/client.txt"
touch "$tmpdir/fail.txt"
# the first tail get swalloed
# idk why so tail twice to ensure
# getting output
# this is a bit ugly but it works
# maybe a sleep does as well
# or I still did not get flushing
tail "$ruby_logfile" &>/dev/null
if [[ "$testname" =~ ^client/ ]]
then
echo "[-] end of ruby client log:"
tail "$ruby_logfile"
echo "[-] end of server log:"
tail "$logdir/server.txt"
else
echo "[-] end of ruby server log:"
tail "$ruby_logfile"
echo "[-] end of client log:"
tail "$logdir/client.txt"
fi
fi
echo "$msg"
exit 1
Expand All @@ -151,14 +155,15 @@ function timeout() {
local seconds="$1"
sleep "$seconds"
echo "[-] Timeout -> killing: $testname"
touch timeout.txt
touch "$tmpdir/timeout.txt"
pkill -f "$testname killme"
kill_all_jobs
fail "[-] Timeout"
}

echo "[*] running test '$testname' ..."
[[ -f timeout.txt ]] && rm timeout.txt
[[ -f "$tmpdir/timeout.txt" ]] && rm "$tmpdir"/timeout.txt
[[ -f "$tmpdir/fail.txt" ]] && rm "$tmpdir"/fail.txt
if [[ "$testname" =~ ^client/ ]]
then
echo "ruby client log $(date)" > "$ruby_logfile"
Expand Down Expand Up @@ -255,7 +260,7 @@ fi
echo "[*] waiting for jobs to finish ..."
wait

if [ -f timeout.txt ]
if [ -f "$tmpdir/timeout.txt" ]
then
echo "[-] Error timeouted"
exit 1
Expand Down

0 comments on commit 8b74e29

Please sign in to comment.