-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunner
More file actions
executable file
·69 lines (64 loc) · 1.75 KB
/
Copy pathrunner
File metadata and controls
executable file
·69 lines (64 loc) · 1.75 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
#!/usr/bin/env bash
set -euo pipefail
usage() {
echo "usage: $0 <workflow|test> [name] [args...]"
exit 1
}
if [[ $# -lt 1 ]]; then
usage
fi
mode="$1"
shift 1
# Use the RUNNER_SCRIPTS_DIR env variable if set, otherwise derive from $0
if [[ -n "${RUNNER_SCRIPTS_DIR:-}" ]]; then
SCRIPT_DIR="${RUNNER_SCRIPTS_DIR}"
else
# Fallback: try to get from PATH or hardcoded location
SCRIPT_DIR="/usr/local/bin"
if [[ ! -d "${SCRIPT_DIR}/workflow" ]]; then
# If not in /usr/local/bin, try to find runner location
RUNNER_PATH=$(command -v runner 2>/dev/null || echo "")
if [[ -n "${RUNNER_PATH}" && "${RUNNER_PATH}" != "runner" ]]; then
SCRIPT_DIR="$(dirname "${RUNNER_PATH}")"
fi
fi
fi
case "$mode" in
test)
if [[ $# -eq 0 ]]; then
# No specific test, run all
for test_dir in "${SCRIPT_DIR}/tests"/*; do
if [[ -d "$test_dir" ]]; then
echo "Running test: $(basename "$test_dir")"
"$test_dir/run.sh"
fi
done
else
# Run a single test
target="$1"
shift 1
test_script="${SCRIPT_DIR}/tests/$target/run.sh"
if [[ ! -x "$test_script" ]]; then
echo "Test '$target' not found: $test_script" >&2
exit 1
fi
"$test_script" "$@"
fi
;;
*)
if [[ $# -lt 1 ]]; then
usage
fi
target="$1"
shift 1
workflow_script="${SCRIPT_DIR}/workflow/${mode}.sh"
if [[ ! -x "$workflow_script" ]]; then
echo "Workflow '$mode' not found: $workflow_script" >&2
echo "DEBUG: SCRIPT_DIR=${SCRIPT_DIR}" >&2
echo "DEBUG: Contents of ${SCRIPT_DIR}/workflow/:" >&2
ls -la "${SCRIPT_DIR}/workflow/" 2>/dev/null || echo " Directory not found" >&2
exit 1
fi
"$workflow_script" "$target" "$@"
;;
esac