-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest
More file actions
executable file
·75 lines (64 loc) · 1.91 KB
/
Copy pathtest
File metadata and controls
executable file
·75 lines (64 loc) · 1.91 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env zsh
# dotfiles/test
#
# Dispatcher for dotfiles test suites. Each suite lives in tests/<name>
# (extensionless, sourced — not executed) so pass/fail/skip counters
# aggregate into a single final summary.
#
# Usage:
# ./test # runs all suites
# ./test <suite> # runs one suite
# ./test santa-faa <rule> # suite-specific sub-filter
# ./test --help # lists suites
set -euo pipefail
# -e exit if any command returns non-zero status code
# -u prevent using undefined variables
# -o pipefail force pipelines to fail on first non-zero status code
/usr/bin/tput sgr0
readonly SCRIPT_DIR="${0:A:h}"
cd "${SCRIPT_DIR}"
# SC1091: source path contains a variable; shellcheck follows it only with
# `-x`. The `source=` directive documents the target for `shellcheck -x` runs.
# shellcheck source=tests/lib disable=SC1091
source "${SCRIPT_DIR}/tests/lib"
readonly -a SUITES=(shellcheck extensions plutil santa-profile linkage completions jump santa-faa npm-attest hook-links)
function _usage {
echo "Usage: ./test [suite [arg]]"
echo "Suites: ${SUITES[*]}"
echo " santa-faa accepts an optional rule filter (ssh-config, git-signing,"
echo " shell-startup, shell-functions, claude-config)"
}
function _run_suite {
local suite="$1"
shift
# shellcheck source=/dev/null
source "${SCRIPT_DIR}/tests/${suite}"
"run_${suite//-/_}" "$@"
}
function main {
local filter="${1:-all}"
case "${filter}" in
-h|--help)
_usage
exit 0
;;
all)
local s
for s in "${SUITES[@]}"; do
_run_suite "${s}"
done
;;
*)
# zsh: (Ie) returns the 1-based index of an exact match, 0 if missing.
if (( ${SUITES[(Ie)${filter}]} == 0 )); then
echo "[FAIL] Unknown suite: ${filter}"
_usage
exit 1
fi
shift
_run_suite "${filter}" "$@"
;;
esac
_print_summary
}
main "$@"