summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2018-05-30 08:32:22 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2018-05-30 11:39:51 -0400
commit96d9b46b7b150cd8a2f7c55721706d4ef994e97a (patch)
tree2e1c9bac0b547bfde3cb8b114eed3d5dc404d28c
parentd2a763e159094147093e92919a3d18f74d91fe17 (diff)
test/testenv: Wrap entire thing in {}
-rwxr-xr-xtest/testenv124
1 files changed, 63 insertions, 61 deletions
diff --git a/test/testenv b/test/testenv
index a744308..29afa30 100755
--- a/test/testenv
+++ b/test/testenv
@@ -1,70 +1,72 @@
#!/usr/bin/env bash
-set -e
+{
+ set -e
-# Parse the arguments
-NETWORK=true
-SUDO=true
-while [[ $# -gt 0 ]]; do
- case "$1" in
- --no-network) shift; unset NETWORK;;
- --network) shift; NETWORK=true;;
- --no-sudo) shift; unset SUDO;;
- --sudo) shift; SUDO=true;;
- --) shift; break;;
- *) break;;
- esac
-done
-export NETWORK SUDO
+ # Parse the arguments
+ NETWORK=true
+ SUDO=true
+ while [[ $# -gt 0 ]]; do
+ case "$1" in
+ --no-network) shift; unset NETWORK;;
+ --network) shift; NETWORK=true;;
+ --no-sudo) shift; unset SUDO;;
+ --sudo) shift; SUDO=true;;
+ --) shift; break;;
+ *) break;;
+ esac
+ done
+ export NETWORK SUDO
-if [[ $# == 0 ]]; then
- echo 'You need to run testenv with arguments!' >&2
- exit 1
-fi
+ if [[ $# == 0 ]]; then
+ echo 'You need to run testenv with arguments!' >&2
+ exit 1
+ fi
-# Set up the working directory, and add the hook to clean it up
-export TMPDIR="$(mktemp --tmpdir -d libretools-test.XXXXXXXXXX)"
-trap "rm -rf '$TMPDIR'" EXIT
+ # Set up the working directory, and add the hook to clean it up
+ export TMPDIR="$(mktemp --tmpdir -d libretools-test.XXXXXXXXXX)"
+ trap "rm -rf '$TMPDIR'" EXIT
-# Set up the install to work with
-destdir=$TMPDIR/destdir
+ # Set up the install to work with
+ destdir=$TMPDIR/destdir
-old_pwd="$(pwd)"
-if [[ -f $0 ]]; then
- cd "${0%/*}"
-fi
-if ! make -C .. install prefix=/usr sysconfdir=/etc DESTDIR="$destdir" &>"$TMPDIR/make-output"; then
- echo 'error creating local install, cannot run tests' >&2
- cat "$TMPDIR/make-output"
- exit 1
-fi
-cd "$old_pwd"
+ old_pwd="$(pwd)"
+ if [[ -f $0 ]]; then
+ cd "${0%/*}"
+ fi
+ if ! make -C .. install prefix=/usr sysconfdir=/etc DESTDIR="$destdir" &>"$TMPDIR/make-output"; then
+ echo 'error creating local install, cannot run tests' >&2
+ cat "$TMPDIR/make-output"
+ exit 1
+ fi
+ cd "$old_pwd"
-# Set up the environment
-export PATH="$destdir/usr/bin:$PATH"
-export LIBRETOOLS_LIBDIR="$destdir/usr/lib/libretools"
-export XBS_LIBDIR="$destdir/usr/lib/xbs"
-export HOME=$TMPDIR/home
-export XDG_CACHE_HOME="$HOME/.cache"
-export XDG_CONFIG_HOME="$HOME/.config"
-export _librelib_conf_sh_sysconfdir="$destdir/etc"
-export _librelib_conf_sh_pkgconfdir="$destdir/etc/libretools.d"
+ # Set up the environment
+ export PATH="$destdir/usr/bin:$PATH"
+ export LIBRETOOLS_LIBDIR="$destdir/usr/lib/libretools"
+ export XBS_LIBDIR="$destdir/usr/lib/xbs"
+ export HOME=$TMPDIR/home
+ export XDG_CACHE_HOME="$HOME/.cache"
+ export XDG_CONFIG_HOME="$HOME/.config"
+ export _librelib_conf_sh_sysconfdir="$destdir/etc"
+ export _librelib_conf_sh_pkgconfdir="$destdir/etc/libretools.d"
-# Hack to respect our variables in sudo
-_sudo() {
- local vars=(TMPDIR PATH LIBRETOOLS_LIBDIR XDG_CACHE_HOME XDG_CONFIG_HOME _librelib_conf_sh_sysconfdir)
- local env=()
- local var
- for var in "${vars[@]}"; do
- env+=("$var=${!var}")
- done
- sudo "${env[@]}" "$@"
-}
-printf '%s\n' \
- '#!/bin/bash' \
- "$(declare -f _sudo)" \
- '_sudo "$@"' \
- > "$destdir/usr/bin/testsudo"
-chmod 755 "$destdir/usr/bin/testsudo"
+ # Hack to respect our variables in sudo
+ _sudo() {
+ local vars=(TMPDIR PATH LIBRETOOLS_LIBDIR XDG_CACHE_HOME XDG_CONFIG_HOME _librelib_conf_sh_sysconfdir)
+ local env=()
+ local var
+ for var in "${vars[@]}"; do
+ env+=("$var=${!var}")
+ done
+ sudo "${env[@]}" "$@"
+ }
+ printf '%s\n' \
+ '#!/bin/bash' \
+ "$(declare -f _sudo)" \
+ '_sudo "$@"' \
+ > "$destdir/usr/bin/testsudo"
+ chmod 755 "$destdir/usr/bin/testsudo"
-# Run the tests
-eval "$@"
+ # Run the tests
+ eval "$@"
+}