54 lines
1.4 KiB
Bash
Executable File
54 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Regression harness for #701: -h/--help must exit 0, bad args must still exit nonzero.
|
|
#
|
|
# Covers the 7 wrappers whose usage() previously hard-coded `exit 1`, so every
|
|
# --help invocation exited nonzero and logged a phantom isError across fleet lanes.
|
|
# Asserts, per wrapper:
|
|
# 1. `--help` exits 0 and prints usage.
|
|
# 2. `-h` exits 0 and prints usage.
|
|
# 3. A genuine unknown flag still exits nonzero (usage() default path untouched).
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
WRAPPERS=(
|
|
issue-assign.sh
|
|
issue-create.sh
|
|
issue-list.sh
|
|
milestone-create.sh
|
|
pr-create.sh
|
|
pr-list.sh
|
|
pr-merge.sh
|
|
)
|
|
|
|
fail=0
|
|
|
|
for wrapper in "${WRAPPERS[@]}"; do
|
|
path="$SCRIPT_DIR/$wrapper"
|
|
|
|
if ! output=$(bash "$path" --help 2>&1); then
|
|
echo "FAIL: $wrapper --help exited nonzero" >&2
|
|
fail=1
|
|
elif [[ "$output" != Usage:* ]]; then
|
|
echo "FAIL: $wrapper --help did not print usage" >&2
|
|
fail=1
|
|
fi
|
|
|
|
if ! bash "$path" -h >/dev/null 2>&1; then
|
|
echo "FAIL: $wrapper -h exited nonzero" >&2
|
|
fail=1
|
|
fi
|
|
|
|
if bash "$path" --this-is-not-a-real-flag >/dev/null 2>&1; then
|
|
echo "FAIL: $wrapper accepted an unknown flag (should have exited nonzero)" >&2
|
|
fail=1
|
|
fi
|
|
done
|
|
|
|
if [[ "$fail" -eq 0 ]]; then
|
|
echo "help-exit-code regression passed (7/7 wrappers)"
|
|
fi
|
|
|
|
exit "$fail"
|