[test] add examples-check target with stubbed BIN and no-network validation for example scripts
This commit is contained in:
26
scripts/bin_stub.sh
Executable file
26
scripts/bin_stub.sh
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
# Lightweight stub for examples-check: simulates the PolyScribe CLI without I/O or network
|
||||
# - Accepts any arguments
|
||||
# - Exits 0
|
||||
# - Produces no output unless VERBOSE_STUB=1
|
||||
# - Never performs network operations
|
||||
# - Never reads from stdin
|
||||
set -euo pipefail
|
||||
|
||||
if [[ "${VERBOSE_STUB:-0}" == "1" ]]; then
|
||||
echo "[stub] polyscribe $*" 1>&2
|
||||
fi
|
||||
|
||||
# Behave quietly if -q/--quiet is present by default (no output)
|
||||
# Honor --help/-h: print minimal usage if verbose requested
|
||||
if [[ "${VERBOSE_STUB:-0}" == "1" ]]; then
|
||||
for arg in "$@"; do
|
||||
if [[ "$arg" == "-h" || "$arg" == "--help" ]]; then
|
||||
echo "PolyScribe stub: no-op (examples-check)" 1>&2
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Always succeed quietly
|
||||
exit 0
|
||||
28
scripts/with_flags.sh
Executable file
28
scripts/with_flags.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
# Wrapper that ensures --no-interaction -q are present, then delegates to the real BIN (stub by default)
|
||||
set -euo pipefail
|
||||
|
||||
REAL_BIN=${REAL_BIN:-"$(dirname "$0")/bin_stub.sh"}
|
||||
|
||||
# Append flags if not already present in args
|
||||
args=("$@")
|
||||
need_no_interaction=1
|
||||
need_quiet=1
|
||||
for a in "${args[@]}"; do
|
||||
[[ "$a" == "--no-interaction" ]] && need_no_interaction=0
|
||||
[[ "$a" == "-q" || "$a" == "--quiet" ]] && need_quiet=0
|
||||
done
|
||||
|
||||
if [[ $need_no_interaction -eq 1 ]]; then
|
||||
args=("--no-interaction" "${args[@]}")
|
||||
fi
|
||||
if [[ $need_quiet -eq 1 ]]; then
|
||||
args=("-q" "${args[@]}")
|
||||
fi
|
||||
|
||||
# Never read stdin; prevent accidental blocking by redirecting from /dev/null
|
||||
# Also advertise offline via env variables commonly checked by the app
|
||||
export CI=1
|
||||
export POLYSCRIBE_MODELS_BASE_COPY_DIR="${POLYSCRIBE_MODELS_BASE_COPY_DIR:-}" # leave empty by default
|
||||
|
||||
exec "$REAL_BIN" "${args[@]}" </dev/null
|
||||
Reference in New Issue
Block a user