forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiBe12d32fTahinli6 days ago3982 commits

link-fixtures.sh74 lines, 2.8 KiBHistoryRawDownload
1#!/usr/bin/env bash
2# link-fixtures.sh — give this worktree the primary checkout's root `fixtures/`.
3#
4# The root `fixtures/` directory is listed in `.gitignore` (line 2) and is NOT
5# committed, so `git worktree add` gives every lane worktree a tree WITHOUT it.
6# Every test that reads a fixture through `<crate>/../../fixtures` then reports
7# green having checked nothing: this is the "gate skips on its own failure"
8# class, and it has already cost false verdicts (lane-av1skipfix 2026-09-29).
9#
10# This script makes a SYMLINK, never a copy: the fixtures are large and the
11# lane worktrees exist to run tests, not to duplicate data.
12#
13# Usage: scripts/link-fixtures.sh [--check]
14# (no args) create the symlink, or no-op if fixtures/ is already there
15# --check report what would happen and exit non-zero if the fixtures are
16# absent; for a batch preflight
17#
18# Idempotent and safe to run from any worktree of this repo.
19
20set -uo pipefail
21
22ROOT=$(cd -- "$(dirname -- "$0")/.." && pwd)
23cd "$ROOT" || exit 2
24
25# `--git-common-dir` resolves to the PRIMARY checkout's .git from any linked
26# worktree (a linked worktree's own .git is a FILE, not the common dir), so
27# this works identically in the primary tree and in ~/.cache/wt/<lane>.
28COMMON=$(git rev-parse --git-common-dir 2>/dev/null) || {
29 echo "link-fixtures: not inside a git repository ($ROOT)" >&2
30 exit 2
31}
32COMMON=$(cd -- "$COMMON" && pwd) || exit 2
33PRIMARY=$(dirname -- "$COMMON")
34SOURCE="$PRIMARY/fixtures"
35
36CHECK=0
37[ "${1:-}" = "--check" ] && CHECK=1
38
39report() { # report <state> <detail>
40 echo "link-fixtures: $1 — $2"
41 echo " primary checkout: $PRIMARY"
42 echo " this tree: $ROOT"
43}
44
45if [ -e "$ROOT/fixtures" ] || [ -L "$ROOT/fixtures" ]; then
46 if [ -L "$ROOT/fixtures" ] && [ -d "$ROOT/fixtures" ]; then
47 report "already linked" "$ROOT/fixtures -> $(readlink -f "$ROOT/fixtures")"
48 exit 0
49 fi
50 if [ -d "$ROOT/fixtures" ]; then
51 report "already a real directory" "nothing to do ($ROOT/fixtures)"
52 exit 0
53 fi
54 report "REFUSING" "$ROOT/fixtures exists but is neither a directory nor a live symlink; remove it by hand" >&2
55 exit 2
56fi
57
58if [ ! -d "$SOURCE" ]; then
59 report "REFUSING" "the primary checkout has no fixtures/ at $SOURCE" >&2
60 echo " It is gitignored, so it exists only where someone generated it:" >&2
61 echo " scripts/gen-fixtures.sh (containers) and scripts/fetch-vectors.sh" >&2
62 echo " (conformance vectors). Run one there, then re-run this script." >&2
63 exit 2
64fi
65
66if [ "$CHECK" = 1 ]; then
67 report "would link" "$ROOT/fixtures -> $SOURCE"
68 exit 1
69fi
70
71ln -s "$SOURCE" "$ROOT/fixtures" || exit 2
72report "linked" "$ROOT/fixtures -> $SOURCE"
73echo " Fixtures are now reachable; run your crate's gates with"
74echo " EC_REQUIRE_FIXTURES=1 so an absent fixture FAILS instead of skipping."