#!/usr/bin/env bash # Runs every selftest in this directory and reports a single verdict. # # bash scripts/selftest.sh # everything # bash scripts/selftest.sh --fast # skip the ones that invoke a compiler # # The compiler-backed tests (hardlink-clone, restore-mtimes) are the ones that # verify behaviour against real Cargo rather than against a fixture, so # --fast is for iterating, not for signing off a change. set -uo pipefail script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) FAST=0 [ "${1:-}" = "--fast" ] && FAST=1 FIXTURE_TESTS=(cache-root-selftest.sh seed-target-dir-selftest.sh publish-snapshot-selftest.sh prune-cache-selftest.sh) CARGO_TESTS=(hardlink-clone-selftest.sh restore-mtimes-selftest.sh) TESTS=("${FIXTURE_TESTS[@]}") if [ "$FAST" = "0" ]; then TESTS+=("${CARGO_TESTS[@]}"); fi failed=() for t in "${TESTS[@]}"; do echo echo "############################################################" echo "# $t" echo "############################################################" if bash "$script_dir/$t"; then echo "--> $t OK" else echo "--> $t FAILED" failed+=("$t") fi done echo if [ "${#failed[@]}" -eq 0 ]; then echo "selftest: all ${#TESTS[@]} suites passed" [ "$FAST" = "1" ] && echo "NOTE: --fast skipped ${CARGO_TESTS[*]}" exit 0 fi echo "selftest: ${#failed[@]} of ${#TESTS[@]} suites FAILED: ${failed[*]}" exit 1