Skip to content

Commit 57f2d14

Browse files
authored
Analogous changes to less destructive test vectors (#381)
1 parent 50cb771 commit 57f2d14

File tree

1 file changed

+18
-59
lines changed

1 file changed

+18
-59
lines changed

scripts/run_test_vectors.sh

Lines changed: 18 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -17,76 +17,35 @@ echo "LOG_PATH: $LOG_PATH"
1717

1818
mkdir -p dump
1919

20-
# Show the repo commit being tested
20+
# Show the commit hashes being used
2121
repo_commit=$(git rev-parse HEAD)
2222
echo "Using repo commit: $repo_commit"
2323

24-
# Pin test-vectors to a specific commit (same mechanism as run_test_vectors.sh)
25-
GIT_REF="${GIT_REF:-$(cat scripts/test-vectors-commit-sha.txt)}"
26-
REPO_URL="https://github.com/firedancer-io/test-vectors.git"
24+
# Get commit SHA from file or env
25+
GIT_REF=${GIT_REF:-$(cat ./scripts/test-vectors-commit-sha.txt)}
2726
echo "Using test-vectors commit: $GIT_REF"
2827

29-
# Prepare local repo for test-vectors and ensure exact commit is checked out
28+
# Fetch/update test-vectors repo
3029
if [ ! -d dump/test-vectors ]; then
3130
echo "Cloning test-vectors repository..."
32-
(cd dump && git clone -q --no-tags --depth=1 "$REPO_URL" test-vectors)
31+
(cd dump && git clone --depth=1 -q https://github.com/firedancer-io/test-vectors.git)
32+
else
33+
echo "Updating test-vectors repository..."
34+
(cd dump/test-vectors && git fetch -q origin "$GIT_REF" || true)
3335
fi
34-
cd dump/test-vectors
35-
36-
safe_checkout() {
37-
local ref="$1"
38-
39-
# Remove stale git lock if present
40-
[ -f .git/index.lock ] && rm -f .git/index.lock
41-
42-
# Ensure remote URL is correct
43-
if git remote get-url origin >/dev/null 2>&1; then
44-
git remote set-url origin "$REPO_URL"
45-
else
46-
git remote add origin "$REPO_URL"
47-
fi
48-
49-
# Clean any outstanding changes or spurious files
50-
git reset -q --hard || true
51-
git clean -q -fdx || true
52-
53-
# Fetch the exact commit (shallow first, fallback to full)
54-
if ! git fetch -q --no-tags --depth=1 origin "$ref"; then
55-
git fetch -q --no-tags origin "$ref"
56-
fi
5736

58-
# Force detached checkout to the commit
59-
git config advice.detachedHead false || true
60-
if ! git checkout --detach -f -q "$ref"; then
61-
git fetch -q --no-tags --prune origin || true
62-
git checkout --detach -f -q "$ref"
37+
# Checkout specific commit non-destructively
38+
(
39+
cd dump/test-vectors
40+
if ! git cat-file -e "$GIT_REF"^{commit} 2>/dev/null; then
41+
echo "Fetching test vectors commit $GIT_REF..."
42+
git fetch -q origin "$GIT_REF"
6343
fi
44+
git checkout -q --detach "$GIT_REF"
45+
)
6446

65-
# Verify HEAD matches the requested commit
66-
local head
67-
head="$(git rev-parse HEAD 2>/dev/null || echo "")"
68-
if [ "$head" != "$ref" ]; then
69-
echo "Failed to checkout exact commit (HEAD=$head, expected $ref)"
70-
return 1
71-
fi
72-
return 0
73-
}
74-
75-
# Only perform checkout if not already at the desired commit
76-
current="$(git rev-parse HEAD || echo '')"
77-
if [ "$current" != "$GIT_REF" ]; then
78-
tries=3
79-
while ! safe_checkout "$GIT_REF"; do
80-
tries=$((tries-1))
81-
[ $tries -le 0 ] && { echo "Failed to checkout $GIT_REF"; exit 128; }
82-
echo "Retrying checkout ($tries retries left)…"
83-
sleep 1
84-
done
85-
fi
86-
87-
# Capture the exact commit we ended up at
88-
test_vectors_commit=$(git rev-parse HEAD)
89-
cd ../..
47+
# Show the commit hashes being used
48+
test_vectors_commit=$(cd dump/test-vectors && git rev-parse HEAD)
9049
echo "Using test-vectors commit: $test_vectors_commit"
9150

9251
# Run one fixture per process, capture per-fixture output, and collect failures/successes.

0 commit comments

Comments
 (0)