-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_all_patches.sh
More file actions
45 lines (35 loc) · 1.03 KB
/
run_all_patches.sh
File metadata and controls
45 lines (35 loc) · 1.03 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
#!/usr/bin/env bash
set -euo pipefail
# Usage: ./run_all_patches.sh <patches-dir> <worktree-dir> <test-command> <results-file>
# Example: ./run_all_patches.sh patches worktree "pytest -q" results.txt
PATCHES_DIR=$1
WORKTREE=$2
TEST_CMD=$3
RESULTS_FILE=$4
# clean results file
: > "$RESULTS_FILE"
for PATCH_FILE in "$PATCHES_DIR"/*.diff; do
PATCH_NAME=$(basename "$PATCH_FILE")
echo "Testing patch: $PATCH_NAME"
# fresh worktree for each patch
rm -rf "$WORKTREE"
git worktree add "$WORKTREE" HEAD
cd "$WORKTREE"
if git apply "$PATCH_FILE"; then
echo "Applied patch: $PATCH_NAME"
else
echo "Failed to apply patch: $PATCH_NAME"
cd ..
git worktree remove --force "$WORKTREE"
continue
fi
echo "Running tests..."
if bash -c "$TEST_CMD"; then
echo "$PATCH_NAME Survived" >> "../$RESULTS_FILE"
else
echo "$PATCH_NAME Killed" >> "../$RESULTS_FILE"
fi
cd ..
git worktree remove --force "$WORKTREE"
done
echo "Summary written to $RESULTS_FILE"