1
0
mirror of https://github.com/sstephenson/bats.git synced 2026-02-26 01:38:11 +01:00

Initial commit

This commit is contained in:
Sam Stephenson
2011-12-28 12:40:14 -06:00
commit c850527cce
4 changed files with 181 additions and 0 deletions

38
libexec/bats Executable file
View File

@@ -0,0 +1,38 @@
#!/usr/bin/env bash
set -e
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"
}
expand_path() {
echo "$(abs_dirname "$(dirname "$1")")/$(basename "$1")"
}
BATS_LIBEXEC="$(abs_dirname "$0")"
export BATS_PREFIX="$(abs_dirname "$BATS_LIBEXEC")"
export PATH="$BATS_LIBEXEC:$PATH"
filename="$1"
if [ -z "$filename" ]; then
echo "usage: $0 <filename>" >&2
exit 1
else
shift
fi
exec bats-exec "$(expand_path "$filename")" "$@"