aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/test-abstraction-ssp.sh
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2026-08-28 19:07:05 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2026-08-28 20:15:35 -0400
commit45a73e4464fb662d481d31ebf8d3ef204296159a (patch)
tree0aa0ef5111f55a6ad6cfce4110fa961d9e2001b1 /test/test-abstraction-ssp.sh
parenttest build .ssp requires --serial (--no-parallel) run (diff)
.ssp: doc structure related fixes (& to epub toc_nav)
for document abstraction and its .ssp output, removed the requirement of including --abstraction & --serial flags to produce correct output (for: .dom_status, .dom_status_collapsed & .last_descendant) - meta_processing_xml_dom() includes show_abstraction, so --pod2 and --show-abstraction run the dom pass; last_descendant is derived from that pass via after_doc_get_descendants() The accumulators are now verified as eight wide locals of docAbstraction(), so each document starts clean and no two threads share one. - bug: the four dom accumulators were template scope (shared) and nine wide, while their end of document reset was eight wide, so the first document of a run differed from the rest and parallel runs raced on one buffer, (which also mis-nested epub toc_nav) test/ reference .ssp regenerated: accelerando only, trailing zero dropped. test-abstraction-ssp.sh now runs parallel and diffs output against a serial run. (assisted by Claude-Code)
Diffstat (limited to 'test/test-abstraction-ssp.sh')
-rwxr-xr-xtest/test-abstraction-ssp.sh39
1 files changed, 35 insertions, 4 deletions
diff --git a/test/test-abstraction-ssp.sh b/test/test-abstraction-ssp.sh
index 5267403..133cfb6 100755
--- a/test/test-abstraction-ssp.sh
+++ b/test/test-abstraction-ssp.sh
@@ -4,6 +4,9 @@
# Regression test for spine's document abstraction.
# Generates .ssp files for all sample documents and diffs
# against committed reference files.
+# Also checks that a parallel run and a serial run of the same documents
+# produce identical .ssp (guards against per-document state leaking
+# between documents or between worker threads).
#
# Usage:
# ./test/test-abstraction-ssp.sh # uses result/bin/spine
@@ -80,7 +83,7 @@ if [ "$GENERATE" = true ]; then
echo "Generating reference .ssp files..."
rm -rf "$REF_DIR"
mkdir -p "$REF_DIR"
- $SPINE_BIN --abstraction --serial --show-abstraction --skip-output --output="$SCRIPT_DIR/reference" "$SAMPLES_DIR"/* 2>&1 | tail -1
+ $SPINE_BIN --show-abstraction --skip-output --output="$SCRIPT_DIR/reference" "$SAMPLES_DIR"/* 2>&1 | tail -1
# flatten language subdirs into reference dir
find "$SCRIPT_DIR/reference" -name "*.ssp" ! -path "$REF_DIR/*" -exec mv {} "$REF_DIR/" \;
# clean up empty language dirs
@@ -101,11 +104,22 @@ fi
echo "Generating current .ssp files..."
rm -rf "$TMP_DIR"
mkdir -p "$TMP_DIR"
-$SPINE_BIN --abstraction --serial --show-abstraction --skip-output --output="$SCRIPT_DIR/current" "$SAMPLES_DIR"/* 2>&1 | tail -1
+$SPINE_BIN --abstraction --show-abstraction --skip-output --output="$SCRIPT_DIR/current" "$SAMPLES_DIR"/* 2>&1 | tail -1
# flatten
find "$SCRIPT_DIR/current" -name "*.ssp" ! -path "$TMP_DIR/*" -exec mv {} "$TMP_DIR/" \;
find "$SCRIPT_DIR/current" -mindepth 1 -type d -empty -delete 2>/dev/null || true
+# generate the same .ssp serially, to check that parallel and serial
+# processing agree (per-document state leaking between documents, or
+# between worker threads, shows up here)
+SER_DIR="$SCRIPT_DIR/current-serial/abstraction"
+echo "Generating current .ssp files (serial)..."
+rm -rf "$SCRIPT_DIR/current-serial"
+mkdir -p "$SER_DIR"
+$SPINE_BIN --show-abstraction --serial --skip-output --output="$SCRIPT_DIR/current-serial" "$SAMPLES_DIR"/* 2>&1 | tail -1
+find "$SCRIPT_DIR/current-serial" -name "*.ssp" ! -path "$SER_DIR/*" -exec mv {} "$SER_DIR/" \;
+find "$SCRIPT_DIR/current-serial" -mindepth 1 -type d -empty -delete 2>/dev/null || true
+
# diff
echo "Comparing against reference..."
FAILURES=0
@@ -135,12 +149,29 @@ for cur_file in "$TMP_DIR"/*.ssp; do
fi
done
+# parallel vs serial determinism
+for cur_file in "$TMP_DIR"/*.ssp; do
+ basename=$(basename "$cur_file")
+ ser_file="$SER_DIR/$basename"
+ if [ ! -f "$ser_file" ]; then
+ echo "MISSING (serial run): $basename"
+ FAILURES=$((FAILURES + 1))
+ continue
+ fi
+ if ! diff -q "$cur_file" "$ser_file" > /dev/null 2>&1; then
+ echo "NON-DETERMINISTIC: $basename (parallel and serial runs differ)"
+ diff --unified=3 "$cur_file" "$ser_file" | head -30
+ echo " ..."
+ FAILURES=$((FAILURES + 1))
+ fi
+done
+
# clean up
-rm -rf "$SCRIPT_DIR/current"
+rm -rf "$SCRIPT_DIR/current" "$SCRIPT_DIR/current-serial"
if [ "$FAILURES" -eq 0 ]; then
REF_COUNT=$(ls "$REF_DIR"/*.ssp | wc -l)
- echo "PASS: all $REF_COUNT .ssp files match reference"
+ echo "PASS: all $REF_COUNT .ssp files match reference (parallel and serial agree)"
exit 0
else
echo "FAIL: $FAILURES difference(s) found"