-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathrun-tests-parallel.sh
More file actions
executable file
·77 lines (63 loc) · 1.84 KB
/
run-tests-parallel.sh
File metadata and controls
executable file
·77 lines (63 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env bash
#
# This script runs unit tests for all packages in parallel and displays a clean summary.
# It captures output to temporary files and shows results at the end.
#
# Usage:
# ./run-tests-parallel.sh
#
set -euo pipefail
# Create a temporary directory for test outputs
tmpdir=$(mktemp -d)
trap "rm -rf $tmpdir" EXIT
echo "Running tests in parallel..."
echo ""
# Run tests in parallel, capturing output
packages=("artcommon" "doozer" "elliott" "pyartcd" "ocp-build-data-validator")
pids=()
for pkg in "${packages[@]}"; do
echo " Starting: $pkg"
uv run pytest --verbose --color=yes "$pkg/tests/" > "$tmpdir/$pkg.out" 2>&1 &
pids+=($!)
done
echo ""
echo "Waiting for tests to complete..."
# Wait for all background jobs and track which failed
failed=0
failed_packages=()
for i in "${!pids[@]}"; do
pkg="${packages[$i]}"
if ! wait "${pids[$i]}"; then
failed=1
failed_packages+=("$pkg")
fi
done
# Display results
echo ""
echo "=========================================="
echo "Test Results Summary"
echo "=========================================="
echo ""
for pkg in "${packages[@]}"; do
if grep -q "FAILED" "$tmpdir/$pkg.out" || grep -q "ERROR" "$tmpdir/$pkg.out"; then
echo "❌ $pkg: FAILED"
else
passed=$(grep -oP '\d+(?= passed)' "$tmpdir/$pkg.out" | tail -1 || echo "0")
echo "✅ $pkg: $passed tests passed"
fi
done
echo ""
# If any tests failed, show full output for failed packages
if [ $failed -ne 0 ]; then
echo "=========================================="
echo "Failed Test Details"
echo "=========================================="
echo ""
for pkg in "${failed_packages[@]}"; do
echo "==================== $pkg ===================="
cat "$tmpdir/$pkg.out"
echo ""
done
exit 1
fi
echo "All tests passed! ✨"