diff options
Diffstat (limited to 'pipeline/read.sh')
| -rwxr-xr-x | pipeline/read.sh | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/pipeline/read.sh b/pipeline/read.sh new file mode 100755 index 0000000..b3129a5 --- /dev/null +++ b/pipeline/read.sh @@ -0,0 +1,47 @@ +#!/bin/sh +# Every reader and both libraries, over every document, into $OUT/read/. +# +# What each produces: +# +# read/ssp-{d,g}/<doc>.txt the .ssp readers' summary +# read/db-{d,g}/<doc>.txt the .ocda.db readers' summary +# read/dump-{d,g}/<doc>.ssp the library's dump, loaded from the .ssp +# read/dump-{d,g}/<doc>.db the same, loaded from the .ocda.db +# +# The dumps are the interesting ones. All four of them should be identical: +# the two serialisations say the same thing, and the two languages read it the +# same way. `diff` says so, and the summary at the end counts it. +set -e +. "$(dirname "$0")/config.sh" +: "${ARTEFACTS:?set ARTEFACTS to a directory of .ssp and .ocda.db files}" +mkdir -p "$OUT/read" +for d in ssp-d ssp-g db-d db-g dump-d dump-g; do mkdir -p "$OUT/read/$d"; done + +list=$(find "$ARTEFACTS" -name '*.ssp' | sort) +[ -n "$LIMIT" ] && list=$(echo "$list" | head -n "$LIMIT") + +n=0; same=0 +for ssp in $list; do + stem=$(basename "$ssp" .ssp); lang=${stem##*.}; uid=${stem%.*} + db=$(find "$ARTEFACTS" -name "$uid.ocda.db" | head -1) + n=$((n+1)) + sh "$(dirname "$0")/one.sh" ssp-d "$ssp" > "$OUT/read/ssp-d/$stem.txt" + sh "$(dirname "$0")/one.sh" ssp-g "$ssp" > "$OUT/read/ssp-g/$stem.txt" + sh "$(dirname "$0")/one.sh" dump-d "$ssp" > "$OUT/read/dump-d/$stem.ssp" + sh "$(dirname "$0")/one.sh" dump-g "$ssp" > "$OUT/read/dump-g/$stem.ssp" + [ -n "$db" ] || continue + sh "$(dirname "$0")/one.sh" db-d "$db" > "$OUT/read/db-d/$stem.txt" + sh "$(dirname "$0")/one.sh" db-g "$db" > "$OUT/read/db-g/$stem.txt" + sh "$(dirname "$0")/one.sh" dump-d "$db" "$lang" > "$OUT/read/dump-d/$stem.db" + sh "$(dirname "$0")/one.sh" dump-g "$db" "$lang" > "$OUT/read/dump-g/$stem.db" + # the four-way agreement, which is the library's whole claim + if cmp -s "$OUT/read/dump-d/$stem.ssp" "$OUT/read/dump-d/$stem.db" \ + && cmp -s "$OUT/read/dump-g/$stem.ssp" "$OUT/read/dump-g/$stem.db" \ + && cmp -s "$OUT/read/dump-d/$stem.ssp" "$OUT/read/dump-g/$stem.ssp" + then same=$((same+1)) + else echo "DUMPS DIFFER $stem" + fi +done +echo +echo "documents read: $n" +echo "all four dumps identical $same" |
