From 620126ab1a1fff783ccf71155e0831f35ae8bf83 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Sat, 1 Jun 2024 15:31:07 +0200 Subject: Remove test directories for distclean In order to leave a clean build directory by distclean, all generated files must be removed. The environment variable DILLO_TEST_LEAVE_FILES can be set to leave the generated test results, which aids debugging when tests fail. --- test/html/driver.sh | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/html/driver.sh b/test/html/driver.sh index 3ab37e41..5c69fcde 100755 --- a/test/html/driver.sh +++ b/test/html/driver.sh @@ -2,7 +2,7 @@ # # File: driver.sh # -# Copyright (C) 2023 Rodrigo Arias Mallo +# Copyright (C) 2023-2024 Rodrigo Arias Mallo # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -55,26 +55,29 @@ function test_file() { fi test_name=$(basename "$html_file") + wdir="${test_name}_wdir" - wdir=$(mktemp -d "${test_name}_XXX") + # Clean any previous files + rm -rf "$wdir" + mkdir -p "$wdir" # Use a FIFO to read the display number - mkfifo $wdir/display.fifo - exec 6<> $wdir/display.fifo + mkfifo "$wdir/display.fifo" + exec 6<> "$wdir/display.fifo" Xvfb -screen 5 1024x768x24 -displayfd 6 & xorgpid=$! # Always kill Xvfb on exit trap "kill $xorgpid" EXIT - read dispnum < $wdir/display.fifo + read dispnum < "$wdir/display.fifo" export DISPLAY=":$dispnum" render_page "$html_file" "$wdir/html.png" render_page "$ref_file" "$wdir/ref.png" # AE = Absolute Error count of the number of different pixels - diffcount=$(compare -metric AE $wdir/html.png $wdir/ref.png $wdir/diff.png 2>&1) + diffcount=$(compare -metric AE "$wdir/html.png" "$wdir/ref.png" "$wdir/diff.png" 2>&1) # The test passes only if both images are identical if [ "$diffcount" = "0" ]; then @@ -86,7 +89,11 @@ function test_file() { fi exec 6>&- - rm $wdir/display.fifo + rm "$wdir/display.fifo" + + if [ -z "$DILLO_TEST_LEAVE_FILES" ]; then + rm -rf "$wdir" + fi return $ret } -- cgit v1.2.3