Files
mev-beta/orig/scripts/test-runner.sh
Administrator c54c569f30 refactor: move all remaining files to orig/ directory
Completed clean root directory structure:
- Root now contains only: .git, .env, docs/, orig/
- Moved all remaining files and directories to orig/:
  - Config files (.claude, .dockerignore, .drone.yml, etc.)
  - All .env variants (except active .env)
  - Git config (.gitconfig, .github, .gitignore, etc.)
  - Tool configs (.golangci.yml, .revive.toml, etc.)
  - Documentation (*.md files, @prompts)
  - Build files (Dockerfiles, Makefile, go.mod, go.sum)
  - Docker compose files
  - All source directories (scripts, tests, tools, etc.)
  - Runtime directories (logs, monitoring, reports)
  - Dependency files (node_modules, lib, cache)
  - Special files (--delete)

- Removed empty runtime directories (bin/, data/)

V2 structure is now clean:
- docs/planning/ - V2 planning documents
- orig/ - Complete V1 codebase preserved
- .env - Active environment config (not in git)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-10 10:53:05 +01:00

130 lines
4.6 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# Reusable, agnostic test runner script
# Can be used in any Go project by adjusting configuration
# Configuration variables
TEST_LEVEL="${TEST_LEVEL:-basic}" # basic, unit, integration, comprehensive, audit
COVERAGE="${COVERAGE:-false}"
OUTPUT_DIR="${OUTPUT_DIR:-test-results}"
PACKAGE_FILTER="${PACKAGE_FILTER:-./...}"
TIMEOUT="${TIMEOUT:-10m}"
JUNIT_OUTPUT="${JUNIT_OUTPUT:-false}"
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
-l|--level)
TEST_LEVEL="$2"
shift 2
;;
-c|--coverage)
COVERAGE=true
shift
;;
-o|--output)
OUTPUT_DIR="$2"
shift 2
;;
-p|--package)
PACKAGE_FILTER="$2"
shift 2
;;
--junit)
JUNIT_OUTPUT=true
shift
;;
-t|--timeout)
TIMEOUT="$2"
shift 2
;;
-h|--help)
echo "Usage: $0 [OPTIONS]"
echo "Run tests with different levels of coverage"
echo ""
echo "Options:"
echo " -l, --level LEVEL Test level: basic, unit, integration, comprehensive, audit (default: basic)"
echo " -c, --coverage Generate coverage report"
echo " -o, --output DIR Output directory (default: test-results)"
echo " -p, --package PKG Package filter (default: ./...)"
echo " --junit Generate JUnit output"
echo " -t, --timeout DURATION Timeout duration (default: 10m)"
echo " -h, --help Show this help"
exit 0
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
echo "Starting test execution (level: $TEST_LEVEL, coverage: $COVERAGE)"
# Create output directory
mkdir -p "$OUTPUT_DIR"
# Run tests based on level
case $TEST_LEVEL in
"basic")
echo "Running basic tests..."
if [ "$COVERAGE" = "true" ]; then
go test -v -short -coverprofile="$OUTPUT_DIR/coverage.out" -covermode=atomic "$PACKAGE_FILTER"
go tool cover -html="$OUTPUT_DIR/coverage.out" -o "$OUTPUT_DIR/coverage.html"
else
go test -v -short "$PACKAGE_FILTER"
fi
;;
"unit")
echo "Running unit tests..."
if [ "$COVERAGE" = "true" ]; then
go test -v ./test/unit/... -coverprofile="$OUTPUT_DIR/coverage.out" -covermode=atomic
go tool cover -html="$OUTPUT_DIR/coverage.out" -o "$OUTPUT_DIR/coverage.html"
else
go test -v ./test/unit/...
fi
;;
"integration")
echo "Running integration tests..."
if [ "$COVERAGE" = "true" ]; then
go test -v ./test/integration/... -coverprofile="$OUTPUT_DIR/coverage.out" -covermode=atomic
go tool cover -html="$OUTPUT_DIR/coverage.out" -o "$OUTPUT_DIR/coverage.html"
else
go test -v ./test/integration/...
fi
;;
"comprehensive")
echo "Running comprehensive tests..."
if [ "$COVERAGE" = "true" ]; then
go test -v ./test/unit/... ./test/integration/... ./test/e2e/... -coverprofile="$OUTPUT_DIR/coverage.out" -covermode=atomic
go tool cover -html="$OUTPUT_DIR/coverage.out" -o "$OUTPUT_DIR/coverage.html"
else
go test -v ./test/unit/... ./test/integration/... ./test/e2e/...
fi
;;
"audit")
echo "Running audit tests..."
if [ "$COVERAGE" = "true" ]; then
go test -v ./test/unit/... ./test/integration/... ./test/e2e/... ./test/property/... ./test/fuzzing/... ./test/security/... -coverprofile="$OUTPUT_DIR/coverage.out" -covermode=atomic
go tool cover -html="$OUTPUT_DIR/coverage.out" -o "$OUTPUT_DIR/coverage.html"
else
go test -v ./test/unit/... ./test/integration/... ./test/e2e/... ./test/property/... ./test/fuzzing/... ./test/security/...
fi
;;
*)
echo "Invalid test level: $TEST_LEVEL. Use: basic, unit, integration, comprehensive, audit"
exit 1
;;
esac
# Generate JUnit output if requested
if [ "$JUNIT_OUTPUT" = "true" ]; then
if command -v go-junit-report &> /dev/null; then
go test -v "$PACKAGE_FILTER" 2>&1 | go-junit-report > "$OUTPUT_DIR/test-results.xml"
else
echo "go-junit-report not found. Install with: go install github.com/jstemmer/go-junit-report@latest"
fi
fi
echo "Test execution completed. Results in $OUTPUT_DIR"