|
| 1 | +set shell := ["bash", "-c"] |
| 2 | + |
| 3 | +# Run all tests across all languages |
| 4 | +test-all: |
| 5 | + just test-rust |
| 6 | + just test-go |
| 7 | + just test-zig |
| 8 | + |
| 9 | +# --- Rust --- |
| 10 | + |
| 11 | +# Run all Rust tests |
| 12 | +test-rust: |
| 13 | + @for project in 2015 2018 2019/aoc_rust 2020/01 2021/_1 2021/_2 2021/_3 2021/_4 2021/_5 2021/_6 2021/_7 2022 2023/rust 2025/rust runner; do \ |
| 14 | + just test-project-rust $project; \ |
| 15 | + done |
| 16 | + |
| 17 | +# Run a specific Rust project if its files or aoc-rust-common changed |
| 18 | +test-project-rust project: |
| 19 | + @mkdir -p .cache/rust |
| 20 | + @SAFE_NAME=$(echo {{project}} | tr '/' '_') |
| 21 | + @# Hash the project dir AND the shared rust library |
| 22 | + @HASH=$(find {{project}} aoc-rust-common -type f -not -path "*/target/*" -not -path "*/.git/*" 2>/dev/null | sort | xargs shasum -a 256 | shasum -a 256 | awk '{print $1}') |
| 23 | + @if [ -z "$HASH" ]; then HASH="empty"; fi |
| 24 | + @if [ -f .cache/rust/$SAFE_NAME.success ] && [ "$(cat .cache/rust/$SAFE_NAME.success)" = "$HASH" ]; then \ |
| 25 | + echo "✅ Rust: {{project}} (Cached)"; \ |
| 26 | + else \ |
| 27 | + echo "🚀 Rust: Running {{project}}..."; \ |
| 28 | + (cd {{project}} && cargo test) && echo "$HASH" > .cache/rust/$SAFE_NAME.success; \ |
| 29 | + fi |
| 30 | + |
| 31 | +# --- Go --- |
| 32 | + |
| 33 | +# Run all Go tests |
| 34 | +test-go: |
| 35 | + @for project in 2017 2019/go 2020/02 2024/golang; do \ |
| 36 | + just test-project-go $project; \ |
| 37 | + done |
| 38 | + |
| 39 | +# Run a specific Go project if its files or aoc-go-common changed |
| 40 | +test-project-go project: |
| 41 | + @mkdir -p .cache/go |
| 42 | + @SAFE_NAME=$(echo {{project}} | tr '/' '_') |
| 43 | + @# Hash the project dir AND the shared go library |
| 44 | + @HASH=$(find {{project}} aoc-go-common -type f -not -path "*/.git/*" 2>/dev/null | sort | xargs shasum -a 256 | shasum -a 256 | awk '{print $1}') |
| 45 | + @if [ -z "$HASH" ]; then HASH="empty"; fi |
| 46 | + @if [ -f .cache/go/$SAFE_NAME.success ] && [ "$(cat .cache/go/$SAFE_NAME.success)" = "$HASH" ]; then \ |
| 47 | + echo "✅ Go: {{project}} (Cached)"; \ |
| 48 | + else \ |
| 49 | + echo "🚀 Go: Running {{project}}..."; \ |
| 50 | + (cd {{project}} && go test ./...) && echo "$HASH" > .cache/go/$SAFE_NAME.success; \ |
| 51 | + fi |
| 52 | + |
| 53 | +# --- Zig --- |
| 54 | + |
| 55 | +# Run all Zig tests |
| 56 | +test-zig: |
| 57 | + @for project in 2021/zig 2024/zig; do \ |
| 58 | + just test-project-zig $project; \ |
| 59 | + done |
| 60 | + |
| 61 | +# Run a specific Zig project if its files changed |
| 62 | +test-project-zig project: |
| 63 | + @mkdir -p .cache/zig |
| 64 | + @SAFE_NAME=$(echo {{project}} | tr '/' '_') |
| 65 | + @HASH=$(find {{project}} -type f -not -path "*/.zig-cache/*" -not -path "*/zig-out/*" -not -path "*/.git/*" 2>/dev/null | sort | xargs shasum -a 256 | shasum -a 256 | awk '{print $1}') |
| 66 | + @if [ -z "$HASH" ]; then HASH="empty"; fi |
| 67 | + @if [ -f .cache/zig/$SAFE_NAME.success ] && [ "$(cat .cache/zig/$SAFE_NAME.success)" = "$HASH" ]; then \ |
| 68 | + echo "✅ Zig: {{project}} (Cached)"; \ |
| 69 | + else \ |
| 70 | + echo "🚀 Zig: Running {{project}}..."; \ |
| 71 | + (cd {{project}} && zig build test) && echo "$HASH" > .cache/zig/$SAFE_NAME.success; \ |
| 72 | + fi |
| 73 | + |
| 74 | +# Clean all test caches |
| 75 | +clean-cache: |
| 76 | + rm -rf .cache |
0 commit comments