-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·57 lines (52 loc) · 2.72 KB
/
test.sh
File metadata and controls
executable file
·57 lines (52 loc) · 2.72 KB
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
#!/usr/bin/env bash
# ----------------------------------------------------------------------------------------------------------------------
# best | Copyright (C) 2020 eth-p | MIT License
#
# Repository: https://github.com/eth-p/best
# Issues: https://github.com/eth-p/best/issues
# ----------------------------------------------------------------------------------------------------------------------
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${HERE}/lib/opt.sh"
# ----------------------------------------------------------------------------------------------------------------------
# Test Files:
# ----------------------------------------------------------------------------------------------------------------------
export TEST_DIR="${HERE}/tests/${TEST_DIR:-test}"
export TEST_PWD="${HERE}/tests/${TEST_PWD:-data}"
export TEST_SHIM_PATH="${HERE}/tests/${TEST_SHIM_PATH:-shim}"
export SNAPSHOT_DIR="${HERE}/tests/${SNAPSHOT_DIR:-test-snapshots}"
# ----------------------------------------------------------------------------------------------------------------------
# Test Environment:
# ----------------------------------------------------------------------------------------------------------------------
export TEST_ENV_LIB="${HERE}/lib"
export TEST_ENV_TEST_HELPERS="${HERE}/tests/helpers"
export TEST_ENV_PATH="${PATH}"
export TEST_ENV_HOME="${HERE}/tests/data"
export TEST_ENV_BEST_EXECUTABLE="${HERE}/bin/best.sh"
export TEST_ENV_TEST_DIR="${TEST_PWD}/meta-tests"
# ----------------------------------------------------------------------------------------------------------------------
# Options:
# ----------------------------------------------------------------------------------------------------------------------
OPT_ARGV=()
SHIFTOPT_SHORT_OPTIONS="PASS"
while shiftopt; do
case "$OPT" in
-S|--system-path-only) export PATH="/bin:/sbin:/usr/bin:/usr/sbin"; TEST_ENV_PATH="/bin:/sbin:/usr/bin:/usr/sbin" ;;
*)
if [[ "$OPT_VAL" ]]; then OPT_ARGV+=("${OPT}=${OPT_VAL}")
else OPT_ARGV+=("$OPT")
fi ;;
esac
done
# ----------------------------------------------------------------------------------------------------------------------
# Initialize:
# ----------------------------------------------------------------------------------------------------------------------
if ! [[ -d "${HERE}/tests/test" ]]; then
git submodule init 'tests'
git submodule update
fi
# ----------------------------------------------------------------------------------------------------------------------
# Main:
# ----------------------------------------------------------------------------------------------------------------------
cd "$HERE" || exit $?
"${BEST:-bin/best.sh}" --verbose --strict --snapshot:show "${OPT_ARGV[@]}"
exit $?