-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathtest
executable file
·60 lines (46 loc) · 1.25 KB
/
test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail -o errtrace
(shopt -p inherit_errexit &>/dev/null) && shopt -s inherit_errexit
export IS_LOBASH_TEST=1
LOBASH_ROOT_DIR="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
export LOBASH_ROOT_DIR
export LOBASH_TEST_DIR=$LOBASH_ROOT_DIR/tests
export LOBASH_USE_DIST
setup_fixture() {
# shellcheck source=./tests/fixture/setup.bash
source "$LOBASH_TEST_DIR"/fixture/setup.bash
}
export -f setup_fixture
if [[ ${1:-} == '-d' ]]; then
shift
if [[ ! -f "$LOBASH_ROOT_DIR/dist/lobash.bash" ]]; then
echo "Not found $LOBASH_ROOT_DIR/dist/lobash.bash" >&2
exit 2
fi
LOBASH_USE_DIST=true
elif [[ "${*: -1}" == -d ]]; then
set -- "${@:1:$#-1}"
if [[ ! -f "$LOBASH_ROOT_DIR/dist/lobash.bash" ]]; then
echo "Not found $LOBASH_ROOT_DIR/dist/lobash.bash" >&2
exit 2
fi
LOBASH_USE_DIST=true
fi
declare -a bats_args=(
--print-output-on-failure
)
if [[ -n ${CI:-} ]]; then
bats_args+=(--tap)
fi
if [[ ${1:-} == '-j' ]] && [[ -n ${2:-} ]]; then
bats_args+=(-j "$2")
shift 2
fi
if [[ -z "${1:-}" ]]; then
test_dirs=("$LOBASH_TEST_DIR"/{,modules})
else
test_dirs=("$1")
fi
export PATH="$LOBASH_TEST_DIR/fixture/bats/bin:${PATH}"
bats --version
exec bats "${bats_args[@]}" "${test_dirs[@]}"