#!/hint/bash # Copyright © Tavian Barnes # SPDX-License-Identifier: 0BSD ## Argument parsing if command -v nproc &>/dev/null; then JOBS=$(nproc) else JOBS=1 fi MAKE= PATTERNS=() SUDO=() STOP=0 CLEAN=1 UPDATE=0 VERBOSE_COMMANDS=0 VERBOSE_ERRORS=0 VERBOSE_SKIPPED=0 VERBOSE_TESTS=0 # Print usage information usage() { color cat <&2 usage >&2 exit 1 ;; *) PATTERNS+=("$arg") ;; esac done read -a MAKE <<<"$MAKE" # Try to resolve the path to $BFS before we cd, while also supporting # --bfs="./bin/bfs -S ids" read -a BFS <<<"${BFS:-$BIN/bfs}" BFS[0]=$(_realpath "$(command -v "${BFS[0]}")") if ((${#PATTERNS[@]} == 0)); then PATTERNS=("*") fi TEST_CASES=() ALL_TESTS=($(cd "$TESTS" && quote {posix,common,bsd,gnu,bfs}/*.sh)) for TEST in "${ALL_TESTS[@]}"; do TEST="${TEST%.sh}" for PATTERN in "${PATTERNS[@]}"; do if [[ $TEST == $PATTERN ]]; then TEST_CASES+=("$TEST") break fi done done if ((${#TEST_CASES[@]} == 0)); then color printf "${RED}error:${RST} No tests matched" >&2 color printf " ${BLD}%s${RST}" "${PATTERNS[@]}" >&2 color printf ".\n\n" >&2 usage >&2 exit 1 fi }