#!/usr/bin/env bash # Helper script to configure, build, and run tests for a given CMake preset. # Usage: scripts/agents/run-tests.sh [ctest-args...] set -euo pipefail if [[ $# -lt 1 ]]; then echo "Usage: $0 [ctest-args...]" >&2 exit 1 fi PRESET="$1" shift echo "Configuring preset: $PRESET" cmake --preset "$PRESET" || { echo "Configure failed for preset: $PRESET"; exit 1; } ROOT_DIR=$(git rev-parse --show-toplevel 2>/dev/null || pwd) read -r GENERATOR BUILD_CONFIG </dev/null 2>&1; then echo "Running tests for preset: $PRESET" ctest --preset "$PRESET" "$@" else echo "Test preset '$PRESET' not found, falling back to 'all' tests." ctest --preset all "$@" fi echo "All tests passed for preset: $PRESET"