Ensure default .geeqierc.xml is used in tests
authorColin Clark <colin.clark@cclark.uk>
Fri, 2 Feb 2024 13:53:05 +0000 (13:53 +0000)
committerColin Clark <colin.clark@cclark.uk>
Fri, 2 Feb 2024 13:53:05 +0000 (13:53 +0000)
Set XDG_* for local tests so that local user file are not affected.

scripts/image-test.sh
scripts/test-all.sh

index 722eba7..2f36cb3 100755 (executable)
 
 xvfb-run --auto-servernum "$1" "$2" &
 
+if [ -z "$XDG_CONFIG_HOME" ]
+then
+       config_home="$HOME/.config"
+else
+       config_home="$XDG_CONFIG_HOME"
+fi
+
 # Wait for remote to initialize
-while [ ! -e "$HOME/.config/geeqie/.command" ] ;
+while [ ! -e "$config_home/geeqie/.command" ] ;
 do
        sleep 1
 done
@@ -40,7 +47,7 @@ sleep 2
 # Check if Geeqie crashed
 if ! pgrep geeqie
 then
-       rm "$HOME/.config/geeqie/.command"
+       rm "$config_home/geeqie/.command"
        exit 1
 fi
 
index 537dc57..666aeca 100755 (executable)
@@ -32,6 +32,13 @@ then
        exit 1
 fi
 
+XDG_CONFIG_HOME=$(mktemp -d "${TMPDIR:-/tmp}/geeqie.XXXXXXXXXX")
+XDG_CACHE_HOME=$(mktemp -d "${TMPDIR:-/tmp}/geeqie.XXXXXXXXXX")
+XDG_DATA_HOME=$(mktemp -d "${TMPDIR:-/tmp}/geeqie.XXXXXXXXXX")
+export XDG_CONFIG_HOME
+export XDG_CACHE_HOME
+export XDG_DATA_HOME
+
 rm --recursive --force build
 
 # Check with all options disabled
@@ -74,3 +81,7 @@ meson setup -Ddevel=enabled build
 meson test -C build
 
 cp ./build/meson-logs/testlog.txt "$tmpdir/testlog-options-enabled.txt"
+
+rm -r "XDG_CONFIG_HOME"
+rm -r "XDG_CACHE_HOME"
+rm -r "XDG_DATA_HOME"