Update test-helper.sh

This commit is contained in:
2014-08-21 02:00:34 +01:00
parent 71bc4d5a44
commit 3cc242429b

View File

@@ -1,12 +1,39 @@
[ -n "$TEST_DEBUG" ] && set -x
resolve_link() {
$(type -p greadlink readlink | head -1) $1
}
abs_dirname() {
local cwd="$(pwd)"
local path="$1"
while [ -n "$path" ]; do
cd "${path%/*}"
local name="${path##*/}"
path="$(resolve_link "$name" || true)"
done
pwd
cd "$cwd"
}
# Set testroot variable.
testroot="$(dirname "$BASH_SOURCE")"
testroot="$(abs_dirname "$BASH_SOURCE")"
# Set root variable.
root="$(abs_dirname "$testroot/../..")"
# Setup PATH environment variable.
PATH="$root/bin:$root/libexec:$PATH"
# Include assert.sh testing library.
source "$testroot/assert.sh"
source "$testroot/stub.sh"
source "${testroot}/assert.sh"
source "${testroot}/stub.sh"
#
# Additional test helpers.
# Test Helpers
#
# Silent shortcut to "cd -".