#!/usr/bin/env bash # Run every test suite for scripts/. No root, network, or real disks needed. # scripts/tests/run.sh all suites # scripts/tests/run.sh fetch only suites whose name contains "fetch" set -u cd -- "$(dirname -- "$(readlink -f -- "$0")")" || exit 1 filter="${1:-}" failed=() skipped=() ran=0 need() { # need SUITE CMD...: skip the suite if a tool is missing local suite="$1" c; shift for c in "$@"; do command -v "$c" >/dev/null 2>&1 || { skipped+=("$suite (needs $c)"); return 1; } done } run_suite() { local name="$1"; shift [[ -z "$filter" || "$name" == *"$filter"* ]] || return 0 printf '\n== %s\n' "$name" ran=$((ran + 1)) "$@" || failed+=("$name") } need python3 python3 && run_suite python python3 -m unittest -q test_python need fetch curl python3 flock && run_suite shell/fetch-iso ./test_fetch_iso.sh run_suite shell/gen-keys ./test_gen_keys.sh run_suite shell/capture-hardware ./test_capture_hardware.sh need docker gpg python3 && run_suite shell/docker-creds ./test_docker_creds.sh need usb script cmp findmnt && run_suite shell/make-usb ./test_make_usb.sh printf '\n' ((${#skipped[@]})) && printf 'SKIPPED: %s\n' "${skipped[@]}" if ((${#failed[@]})); then printf 'FAILED suites: %s\n' "${failed[*]}" exit 1 fi printf 'All %d suite(s) passed.\n' "$ran"