test-roundtrip.sh
#!/bin/bash ## Roundtrip, for both sigil dialects: export is regeneration-stable, ## verify passes, and import into a fresh clone of upstream reproduces the ## exact branch tips, fsck-clean. set -euo pipefail cd "$(dirname "$0")" source ./lib.sh work=$(mktemp -d) trap 'rm -rf "$work"' EXIT make_corpus "$work/corpus" source "$work/corpus/FACTS" for sigil in quote tab; do p="$work/$sigil" "$PATCHETTE" export "--sigil=$sigil" --subject="$work/corpus/dev" --patches="$p/patches" "$base" topic/fancy docs-polish odd-bytes >/dev/null "$PATCHETTE" export "--sigil=$sigil" --subject="$work/corpus/dev" --patches="$p/again" "$base" topic/fancy docs-polish odd-bytes >/dev/null EXPECT success "$sigil: export is regeneration-stable (two runs byte-identical)" -- \ diff -r "$p/patches" "$p/again" # Guard the guard: confirm the flag actually switched the emitted framing, # or this loop would just test the quote dialect twice. sample="$p/patches/topic¦fancy/teach-gizmo-to-hum.patch" case $sigil in quote) want=$'> The hum is load-bearing.' ;; tab) want=$'\tThe hum is load-bearing.' ;; esac EXPECT success "$sigil: emitted message framing matches the dialect" -- \ grep -qxF "$want" "$sample" EXPECT success "$sigil: verify passes on a fresh export" -- \ "$PATCHETTE" verify --subject="$work/corpus/dev" --patches="$p/patches" # The recreate story: upstream has none of our branches; the patches repo # alone must bring them back, byte-exact. git clone -q "$work/corpus/upstream" "$p/fresh" "$PATCHETTE" import --subject="$p/fresh" --patches="$p/patches" >/dev/null EXPECT equal "$sigil: import reproduces the exact topic/fancy tip" -- \ "$(git -C "$p/fresh" rev-parse refs/heads/topic/fancy)" "$tip_topic_fancy" EXPECT equal "$sigil: import reproduces the exact docs-polish tip" -- \ "$(git -C "$p/fresh" rev-parse refs/heads/docs-polish)" "$tip_docs_polish" EXPECT equal "$sigil: import reproduces the exact odd-bytes tip" -- \ "$(git -C "$p/fresh" rev-parse refs/heads/odd-bytes)" "$tip_odd_bytes" EXPECT success "$sigil: fsck --strict clean on the replayed repo" -- \ git -C "$p/fresh" fsck --strict done exit "$RESULT"
tests/test-roundtrip.sh · 2.1 KiB · 89427c2482