summaryrefslogtreecommitdiff
path: root/test/testenv
diff options
context:
space:
mode:
Diffstat (limited to 'test/testenv')
-rwxr-xr-xtest/testenv17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/testenv b/test/testenv
index 12a5901..e6f49fb 100755
--- a/test/testenv
+++ b/test/testenv
@@ -39,5 +39,22 @@ export HOME=$TMPDIR/home
export XDG_CACHE_HOME="$HOME/.cache"
export XDG_CONFIG_HOME="$HOME/.config"
+# Hack to respect our variables in sudo
+_sudo() {
+ local vars=(TMPDIR PATH LIBRETOOLS_LIBDIR XDG_CACHE_HOME XDG_CONFIG_HOME)
+ local args=()
+ local var
+ for var in "${vars[@]}"; do
+ args+=("$var=${!var}")
+ done
+ sudo env "${args[@]}" "$@"
+}
+printf '%s\n' \
+ '#!/bin/bash' \
+ "$(declare -f _sudo)" \
+ '_sudo "$@"' \
+ > "$destdir/usr/bin/testsudo"
+chmod 755 "$destdir/usr/bin/testsudo"
+
# Run the tests
eval "$@"