aboutsummaryrefslogtreecommitdiffhomepage
path: root/org
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2026-09-21 15:54:37 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2026-09-22 17:24:15 -0400
commit21979975f0323b299615b01aa58dac9b4d7aad03 (patch)
tree89f91845fae9294d25de9443d7ce7451ef66b505 /org
parentread: db names outputs from manifest carried (diff)
test: language alignment, (live-manual)
The ja and pl translations were mended in the sample set, so the two divergences this script asserted by name are gone. It failed and named every stale expectation, which is what it was for. The reference set is regenerated with two files affected: live-manual.ja.ssp and live-manual.pl.ssp. (assisted by Claude-Code)
Diffstat (limited to 'org')
-rw-r--r--org/tests_for_document_abstraction_shell_scripts.org150
1 files changed, 94 insertions, 56 deletions
diff --git a/org/tests_for_document_abstraction_shell_scripts.org b/org/tests_for_document_abstraction_shell_scripts.org
index 793d69f..41ce11e 100644
--- a/org/tests_for_document_abstraction_shell_scripts.org
+++ b/org/tests_for_document_abstraction_shell_scripts.org
@@ -962,23 +962,26 @@ fi
# test-ocn-alignment.sh
#
# The languages of a document share their object numbering, and spine warns
-# when they stop doing so. This checks that the warning appears where it
-# should and, just as importantly, nowhere else.
-#
-# The sample set is the fixture, and it is a good one because it contains
-# both answers:
-#
-# live-manual ten languages, two of which diverge.
-# ja has two fewer numbered objects than en. A missing
-# translation of a short paragraph; everything below it
-# is renumbered.
-# pl has the same count, but the object at ocn 313 is a
-# paragraph in en and a heading in pl. A heading given as
-# running text, or running text given as a heading.
-# everything else single language, or aligned. Silent.
-#
-# A check that only ever fires is as useless as one that never does, so the
-# silence over the other documents is asserted too.
+# when they stop doing so. This checks both halves of that: that the sample
+# set is silent, and that a document whose languages really do diverge is
+# reported.
+#
+# Two fixtures, because one cannot say both things:
+#
+# the sample set every document aligned, so nothing is reported at
+# all. This is the half that would fail if a change
+# made the check cry wolf, and the half that changed on
+# 2026-09-18 when live-manual's ja and pl translations
+# were mended. Until then ja was two objects short of
+# en and pl had a stray heading at ocn 313, and this
+# script asserted those two by name.
+#
+# a broken copy live-manual copied out of the sample set with one
+# paragraph removed from one language, which is a count
+# divergence and must be reported. Built here rather
+# than relied upon, so that mending a translation
+# cannot quietly leave the check untested. A check that
+# never fires proves as little as one that always does.
#
# It also asserts that --strict turns the warning into a non-zero exit, and
# that without --strict the run still succeeds: a document with a diverging
@@ -1050,70 +1053,105 @@ if [ "$RUN_RC" -ne 0 ]; then
head -5 "$OUT_DIR/run.err"
fi
-# what it said
-if ! grep -q "^WARNING ocn alignment: live-manual$" "$OUT_DIR/run.err"; then
- fail "no ocn alignment warning for live-manual"
+# it must say nothing at all: every document in the set is aligned
+n_docs=$(grep -c "^WARNING ocn alignment: " "$OUT_DIR/run.err" || true)
+if [ "$n_docs" != "0" ]; then
+ fail "$n_docs document(s) reported over the sample set, expected none"
+ grep -A 3 "^WARNING ocn alignment: " "$OUT_DIR/run.err" | head -12 | sed 's/^/ /'
+fi
+
+# --strict over the whole set therefore passes too
+set +e
+$SPINE_BIN --show-abstraction --skip-output --strict \
+ --output="$OUT_DIR/strict-ok" "$SAMPLES_DIR"/live-manual \
+ > "$OUT_DIR/strict-ok.out" 2> "$OUT_DIR/strict-ok.err"
+STRICT_OK_RC=$?
+set -e
+if [ "$STRICT_OK_RC" -ne 0 ]; then
+ fail "--strict exited $STRICT_OK_RC on a document whose languages agree"
+ head -5 "$OUT_DIR/strict-ok.err"
fi
-if ! grep -q "^ \[ja\] differs from \[en\]$" "$OUT_DIR/run.err"; then
- fail "ja not reported as differing from en"
+
+# and now the other half: a document that really does diverge.
+#
+# Built here, from a copy, by removing one paragraph from one language. The
+# sample set no longer contains a divergence, and a check that never fires
+# proves as little as one that always does.
+echo "Breaking a copy, to see the check fire ..."
+BROKEN="$OUT_DIR/broken"
+mkdir -p "$BROKEN"
+cp -a "$SAMPLES_DIR/live-manual" "$BROKEN/live-manual"
+TARGET="$BROKEN/live-manual/media/text/de/about_manual.ssi"
+if [ ! -f "$TARGET" ]; then
+ echo "ERROR: fixture not found: $TARGET" >&2
+ exit 2
fi
-if ! grep -q "numbered objects: en 1019, ja 1017 (-2)" "$OUT_DIR/run.err"; then
- fail "ja's object count difference not reported as -2"
+# the first paragraph after the first heading, whole: a numbered object, so
+# removing it renumbers everything below it in this language and no other.
+#
+# The whole of it, to the blank line that ends it. Dropping a single line of
+# a wrapped paragraph leaves the paragraph there, one line shorter, and the
+# object count unchanged: the first version of this fixture did that and the
+# check correctly said nothing.
+awk '
+ BEGIN { state = 0 }
+ state == 0 && /^[A-Za-z]/ && !/^[0-9A-D]~/ && !/^:[A-D]~/ && !/^%/ && !/^@/ \
+ { state = 1; next }
+ state == 1 && /^[[:space:]]*$/ { state = 2; next }
+ state == 1 { next }
+ { print }
+' "$TARGET" > "$TARGET.new" && mv "$TARGET.new" "$TARGET"
+
+set +e
+$SPINE_BIN --show-abstraction --skip-output \
+ --output="$OUT_DIR/broken-out" "$BROKEN/live-manual" \
+ > "$OUT_DIR/broken.out" 2> "$OUT_DIR/broken.err"
+BROKEN_RC=$?
+set -e
+if [ "$BROKEN_RC" -ne 0 ]; then
+ fail "the run over the broken copy exited $BROKEN_RC; a warning must not fail a run"
+ head -5 "$OUT_DIR/broken.err"
fi
-if ! grep -q "^ \[pl\] differs from \[en\]$" "$OUT_DIR/run.err"; then
- fail "pl not reported as differing from en"
+if ! grep -q "^WARNING ocn alignment: live-manual$" "$OUT_DIR/broken.err"; then
+ fail "the removed paragraph was not reported"
+ head -5 "$OUT_DIR/broken.err" | sed 's/^/ /'
fi
-if ! grep -q "ocn 313: para in en, heading:2 in pl" "$OUT_DIR/run.err"; then
- fail "pl's substituted heading at ocn 313 not reported"
+if ! grep -q "^ \[de\] differs from \[en\]$" "$OUT_DIR/broken.err"; then
+ fail "de not reported as differing from en"
fi
-
-# and what it did not say: exactly one document warned about, exactly two
-# languages of it
-n_docs=$(grep -c "^WARNING ocn alignment: " "$OUT_DIR/run.err" || true)
-if [ "$n_docs" != "1" ]; then
- fail "$n_docs documents warned about, expected 1"
- grep "^WARNING ocn alignment: " "$OUT_DIR/run.err" | sed 's/^/ /'
+if ! grep -q "numbered objects: en .*, de .* (-1)" "$OUT_DIR/broken.err"; then
+ fail "de's object count not reported as one short"
+ grep "numbered objects" "$OUT_DIR/broken.err" | sed 's/^/ /'
fi
-n_langs=$(grep -c "^ \[.*\] differs from " "$OUT_DIR/run.err" || true)
-if [ "$n_langs" != "2" ]; then
- fail "$n_langs languages reported, expected 2 (ja and pl)"
- grep "^ \[.*\] differs from " "$OUT_DIR/run.err" | sed 's/^/ /'
+# only the language that was broken
+n_langs=$(grep -c "^ \[.*\] differs from " "$OUT_DIR/broken.err" || true)
+if [ "$n_langs" != "1" ]; then
+ fail "$n_langs languages reported on the broken copy, expected 1 (de)"
+ grep "^ \[.*\] differs from " "$OUT_DIR/broken.err" | sed 's/^/ /'
fi
-# --strict makes the same run fail
+# and --strict makes that a failed run
set +e
$SPINE_BIN --show-abstraction --skip-output --strict \
- --output="$OUT_DIR/strict" "$SAMPLES_DIR"/live-manual \
- > "$OUT_DIR/strict.out" 2> "$OUT_DIR/strict.err"
+ --output="$OUT_DIR/broken-strict" "$BROKEN/live-manual" \
+ > "$OUT_DIR/broken-strict.out" 2> "$OUT_DIR/broken-strict.err"
STRICT_RC=$?
set -e
if [ "$STRICT_RC" -eq 0 ]; then
fail "--strict exited 0 on a document whose languages diverge"
fi
-# and does not fail a document whose languages agree, or one that has only
-# the one language
-set +e
-$SPINE_BIN --show-abstraction --skip-output --strict \
- --output="$OUT_DIR/strict-ok" "$SAMPLES_DIR"/the_wealth_of_networks.yochai_benkler \
- > "$OUT_DIR/strict-ok.out" 2> "$OUT_DIR/strict-ok.err"
-STRICT_OK_RC=$?
-set -e
-if [ "$STRICT_OK_RC" -ne 0 ]; then
- fail "--strict exited $STRICT_OK_RC on a single language document"
- head -5 "$OUT_DIR/strict-ok.err"
-fi
-
rm -rf "$OUT_DIR"
if [ "$FAILURES" -eq 0 ]; then
- echo "PASS: ja and pl reported on live-manual, silent elsewhere, --strict fails"
+ echo "PASS: the sample set is aligned, a broken copy is reported, --strict fails"
exit 0
else
echo "FAIL: $FAILURES check(s)"
exit 1
fi
#+END_SRC
+
** 6. test acceptance db to pod
#+HEADER: :tangle ../test/test-acceptance-db-to-pod.sh