cat / goq
clone

turns a linux box into a private steam streaming appliance: plug in, tap your key, play from another computer

fix/architecture-review-findings
goq / scripts / run-shell-tests.sh
run-shell-tests.sh 1.8K executable
1#!/usr/bin/env bash23set -euo pipefail45LC_ALL=C6export LC_ALL78test_dir="${1:-}"9if [[ -z "$test_dir" ]]; then10 printf 'usage: %s TEST_DIRECTORY\n' "${0##*/}" >&211 exit 212fi13if [[ -L "$test_dir" || ! -d "$test_dir" ]]; then14 printf 'shell test directory must be a real directory: %s\n' "$test_dir" >&215 exit 116fi17if [[ ! -r "$test_dir" || ! -x "$test_dir" ]]; then18 printf 'shell test directory must be readable and searchable: %s\n' "$test_dir" >&219 exit 120fi2122# Bash expands this array in LC_ALL=C order. dotglob makes a test such as23# `.release-contract.sh` part of the same inventory, while nullglob lets us24# diagnose an empty inventory instead of trying to execute a literal glob.25shopt -s dotglob nullglob26shell_tests=("$test_dir"/*.sh)27shopt -u dotglob nullglob2829if (( ${#shell_tests[@]} == 0 )); then30 printf 'no shell tests were discovered in: %s\n' "$test_dir" >&231 exit 132fi3334# Validate the complete inventory before running its first entry. This keeps a35# malformed or non-executable test late in the sort order from producing a36# partially successful gate.37for shell_test in "${shell_tests[@]}"; do38 printf 'shell_test_discovered=%s\n' "$shell_test"39 if [[ "$shell_test" == *$'\n'* || "$shell_test" == *$'\r'* ]]; then40 printf 'shell test path contains an unsafe line break: %q\n' "$shell_test" >&241 exit 142 fi43 if [[ -L "$shell_test" || ! -f "$shell_test" ]]; then44 printf 'shell test entry must be a regular, non-symlink file: %s\n' \45 "$shell_test" >&246 exit 147 fi48 if [[ ! -r "$shell_test" ]]; then49 printf 'shell test entry is not readable: %s\n' "$shell_test" >&250 exit 151 fi52 if [[ ! -x "$shell_test" ]]; then53 printf 'shell test entry is not executable: %s\n' "$shell_test" >&254 exit 155 fi56done5758for shell_test in "${shell_tests[@]}"; do59 printf 'shell_test_start=%s\n' "$shell_test"60 bash "$shell_test"61done