summaryrefslogtreecommitdiff
path: root/test/testenv
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-09-11 01:28:25 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-09-11 15:23:29 -0400
commit589186164cfbb1e033b9dfad33c9bf82b9404b1c (patch)
tree3919316871a4b17c35d2b74971c86b52f1ae73b0 /test/testenv
parent76b27c5c5a705770fbab763199dd32efc279170a (diff)
test: change how we do sudo (to make sure we stay in the test environment)
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 "$@"