#!/usr/bin/env bash # SPDX-License-Identifier: AGPL-3.0-or-later # QA-CORPUS-401-031: Deterministic runner for reachability corpus tests set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)" TEST_PROJECT="${REPO_ROOT}/tests/reachability/StellaOps.Reachability.FixtureTests/StellaOps.Reachability.FixtureTests.csproj" # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color log_info() { echo -e "${GREEN}[INFO]${NC} $*"; } log_warn() { echo -e "${YELLOW}[WARN]${NC} $*"; } log_error() { echo -e "${RED}[ERROR]${NC} $*"; } # Parse arguments FILTER="" VERBOSITY="normal" CONFIGURATION="Release" NO_BUILD=false while [[ $# -gt 0 ]]; do case $1 in --filter) FILTER="$2" shift 2 ;; --verbosity|-v) VERBOSITY="$2" shift 2 ;; --configuration|-c) CONFIGURATION="$2" shift 2 ;; --no-build) NO_BUILD=true shift ;; --help|-h) echo "Usage: $0 [options]" echo "" echo "Options:" echo " --filter xUnit filter pattern (e.g., 'CorpusFixtureTests')" echo " --verbosity, -v Test verbosity (quiet, minimal, normal, detailed, diagnostic)" echo " --configuration, -c Build configuration (Debug, Release)" echo " --no-build Skip build step" echo " --help, -h Show this help" echo "" echo "Examples:" echo " $0 # Run all fixture tests" echo " $0 --filter CorpusFixtureTests # Run only corpus tests" echo " $0 --filter ReachbenchFixtureTests # Run only reachbench tests" exit 0 ;; *) log_error "Unknown option: $1" exit 1 ;; esac done cd "${REPO_ROOT}" log_info "Reachability Corpus Test Runner" log_info "Repository root: ${REPO_ROOT}" log_info "Test project: ${TEST_PROJECT}" # Verify prerequisites if ! command -v dotnet &> /dev/null; then log_error "dotnet CLI not found. Please install .NET SDK." exit 1 fi # Verify corpus exists if [[ ! -f "${REPO_ROOT}/tests/reachability/corpus/manifest.json" ]]; then log_error "Corpus manifest not found at tests/reachability/corpus/manifest.json" exit 1 fi if [[ ! -f "${REPO_ROOT}/tests/reachability/fixtures/reachbench-2025-expanded/INDEX.json" ]]; then log_error "Reachbench INDEX not found at tests/reachability/fixtures/reachbench-2025-expanded/INDEX.json" exit 1 fi # Build if needed if [[ "${NO_BUILD}" == false ]]; then log_info "Building test project (${CONFIGURATION})..." dotnet build "${TEST_PROJECT}" -c "${CONFIGURATION}" --nologo fi # Build test command TEST_CMD="dotnet test ${TEST_PROJECT} -c ${CONFIGURATION} --no-build --verbosity ${VERBOSITY}" if [[ -n "${FILTER}" ]]; then TEST_CMD="${TEST_CMD} --filter \"FullyQualifiedName~${FILTER}\"" log_info "Running tests with filter: ${FILTER}" else log_info "Running all fixture tests..." fi # Run tests log_info "Executing: ${TEST_CMD}" eval "${TEST_CMD}" EXIT_CODE=$? if [[ ${EXIT_CODE} -eq 0 ]]; then log_info "All tests passed!" else log_error "Some tests failed (exit code: ${EXIT_CODE})" fi exit ${EXIT_CODE}