32 lines
1.3 KiB
Bash
Executable File
32 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# ponytail: one assert-based check, no framework.
|
|
|
|
S=$(dirname "$0")/orchestra_worktree_report.sh
|
|
|
|
fail() { printf 'FAIL: %s\n' "$1" >&2; exit 1; }
|
|
|
|
out=$(bash "$S" --help) || fail '--help exited non-zero'
|
|
case "$out" in *Usage:*) ;; *) fail '--help printed no usage' ;; esac
|
|
|
|
out=$(bash "$S") || fail 'no-args exited non-zero'
|
|
case "$out" in *"/tmp/test-e2e-worktrees"*) ;; *) fail 'summary missing worktrees path' ;; esac
|
|
case "$out" in *"/tmp/test-e2e is a git repository"*) ;; *) fail 'summary missing repo check' ;; esac
|
|
|
|
out=$(bash "$S" --json) || fail '--json exited non-zero'
|
|
[ "$(printf '%s\n' "$out" | wc -l)" = 1 ] || fail '--json printed more than one line'
|
|
case "$out" in '{'*'}') ;; *) fail '--json is not one object' ;; esac
|
|
for k in worktrees_dir_exists worktrees_entries repo_is_git; do
|
|
case "$out" in *"\"$k\":"*) ;; *) fail "--json missing key $k" ;; esac
|
|
done
|
|
n=${out#*\"worktrees_entries\":}
|
|
n=${n%%,*}
|
|
case "$n" in ''|*[!0-9]*) fail 'worktrees_entries is not digits' ;; esac
|
|
|
|
err=$(bash "$S" --bogus 2>&1 >/dev/null)
|
|
[ $? -ne 0 ] || fail '--bogus exited 0'
|
|
case "$err" in *"unknown argument"*) ;; *) fail '--bogus printed no stderr message' ;; esac
|
|
[ -z "$(bash "$S" --bogus 2>/dev/null)" ] || fail '--bogus wrote to stdout'
|
|
|
|
printf 'OK\n'
|
|
exit 0
|