summaryrefslogtreecommitdiffhomepage
path: root/pipeline
diff options
context:
space:
mode:
Diffstat (limited to 'pipeline')
-rw-r--r--pipeline/README.md7
-rwxr-xr-xpipeline/build.sh8
-rwxr-xr-xpipeline/one.sh6
-rwxr-xr-xpipeline/pdf.sh2
-rwxr-xr-xpipeline/read.sh21
-rwxr-xr-xpipeline/run.sh2
-rwxr-xr-xpipeline/write.sh2
7 files changed, 36 insertions, 12 deletions
diff --git a/pipeline/README.md b/pipeline/README.md
index 59b98dc..c5920f7 100644
--- a/pipeline/README.md
+++ b/pipeline/README.md
@@ -65,11 +65,13 @@ sh pipeline/one.sh md-g <doc>.ocda.db en
sh pipeline/one.sh html-d <doc>.sisupod
sh pipeline/one.sh dump-d <doc>.ocda.db en
sh pipeline/one.sh agree-g <doc>.ssp <doc>.ocda.db
+sh pipeline/one.sh read-d <doc>.sisupod en --tree
```
The tool names are `<format>-<language>`: `text`, `md`, `html`, `epub`,
-`typst` for the writers, and `ssp`, `db`, `dump`, `agree` for the readers and
-the library; `-d` for D and `-g` for Gleam.
+`typst` for the writers, `read` for the library's reader (ocda-read, which
+reads every form and takes its modes after the file), and `ssp`, `db`, `dump`,
+`agree` for the older readers and the library; `-d` for D and `-g` for Gleam.
Output goes to stdout, so a comparison is a pipeline. The epub and the typst
name a file instead, because an epub is a zip and a `.typ` names its images by
@@ -88,6 +90,7 @@ regression without reading 36 documents.
| `all four dumps identical` | the library's whole claim: two serialisations, two languages, one model |
|---|---|
+| `ocda-read, all four identical` | the reader's tree of a document, the same from its .ssp and its .ocda.db, in D and in Gleam |
| `D == Gleam, <format>` | the writers agree, in unrelated languages, neither written from the other. This is what says the model is sufficient |
| `.ssp and .ocda.db give the same .typ` | a writer is not told which serialisation it was handed |
| `typst compiled silently` | a link to a label that does not exist is a typst compile error, so this says every internal link in every document resolves |
diff --git a/pipeline/build.sh b/pipeline/build.sh
index e4eac9c..72c9b11 100755
--- a/pipeline/build.sh
+++ b/pipeline/build.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env sh
# Build every reader, every library and every writer, in both languages.
#
# Each project is its own flake and builds on its own. The library has no
@@ -19,8 +19,10 @@ build() { # <directory> [flake output]
}
failed=0
-build "$OCDA_LIB/dlang" .#ocda-dump
-build "$OCDA_LIB/dlang" .#ocda-agree
+# the library's programs: ocda-read, ocda-dump and ocda-agree, one build, one
+# result/bin. Built as two, into the one result link, the second replaced the
+# first, and the dump this pipeline reads was not there.
+build "$OCDA_LIB/dlang"
build "$OCDA_LIB/gleam"
build "$SSP_READER/dlang"
build "$SSP_READER/gleam"
diff --git a/pipeline/one.sh b/pipeline/one.sh
index 18ffc5f..55e9ca6 100755
--- a/pipeline/one.sh
+++ b/pipeline/one.sh
@@ -1,10 +1,12 @@
-#!/bin/sh
+#!/usr/bin/env sh
# One tool, one document: the answer to "how do I run this by hand?".
#
# sh pipeline/one.sh <tool> <file> [lang]
#
# where <tool> is one of
#
+# read-d read-g ocda-read, the library's reader of every form; takes its
+# modes after the file: one.sh read-d <file> en --tree
# ssp-d ssp-g the .ssp readers, D and Gleam
# db-d db-g the .ocda.db readers
# dump-d dump-g the library's canonical dump of the whole model
@@ -24,6 +26,8 @@ file=${2:?usage: one.sh <tool> <file> [lang]}
lang=${3:-}
case $tool in
+ read-d) shift; exec "$OCDA_LIB/dlang/result/bin/ocda-read" "$@" ;;
+ read-g) shift; exec "$OCDA_LIB/gleam/result/bin/ocda-read" "$@" ;;
ssp-d) exec "$SSP_READER/dlang/result/bin/ssp-reader" "$file" ;;
ssp-g) exec "$SSP_READER/gleam/result/bin/ssp_reader" "$file" ;;
db-d) exec "$DB_READER/dlang/result/bin/ocda-db-reader" "$file" ;;
diff --git a/pipeline/pdf.sh b/pipeline/pdf.sh
index a769137..d31c1da 100755
--- a/pipeline/pdf.sh
+++ b/pipeline/pdf.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env sh
# Compile every .typ the write stage produced, into $OUT/write/pdf/.
#
# typst is the only thing this stage needs, and it is a single binary. A link
diff --git a/pipeline/read.sh b/pipeline/read.sh
index b3129a5..ddbebe4 100755
--- a/pipeline/read.sh
+++ b/pipeline/read.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env sh
# Every reader and both libraries, over every document, into $OUT/read/.
#
# What each produces:
@@ -7,6 +7,8 @@
# 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
+# read/read-{d,g}/<doc>.ssp ocda-read --tree, reading the .ssp
+# read/read-{d,g}/<doc>.db the same, reading 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
@@ -15,12 +17,12 @@ 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
+for d in ssp-d ssp-g db-d db-g dump-d dump-g read-d read-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
+n=0; same=0; read_same=0
for ssp in $list; do
stem=$(basename "$ssp" .ssp); lang=${stem##*.}; uid=${stem%.*}
db=$(find "$ARTEFACTS" -name "$uid.ocda.db" | head -1)
@@ -41,7 +43,20 @@ for ssp in $list; do
then same=$((same+1))
else echo "DUMPS DIFFER $stem"
fi
+ # ocda-read: the same from either form, and the same in either language,
+ # the first line, which names the file read, set aside
+ sh "$(dirname "$0")/one.sh" read-d "$ssp" "$lang" --tree | tail -n +2 > "$OUT/read/read-d/$stem.ssp"
+ sh "$(dirname "$0")/one.sh" read-g "$ssp" "$lang" --tree | tail -n +2 > "$OUT/read/read-g/$stem.ssp"
+ sh "$(dirname "$0")/one.sh" read-d "$db" "$lang" --tree | tail -n +2 > "$OUT/read/read-d/$stem.db"
+ sh "$(dirname "$0")/one.sh" read-g "$db" "$lang" --tree | tail -n +2 > "$OUT/read/read-g/$stem.db"
+ if cmp -s "$OUT/read/read-d/$stem.ssp" "$OUT/read/read-d/$stem.db" \
+ && cmp -s "$OUT/read/read-g/$stem.ssp" "$OUT/read/read-g/$stem.db" \
+ && cmp -s "$OUT/read/read-d/$stem.ssp" "$OUT/read/read-g/$stem.ssp"
+ then read_same=$((read_same+1))
+ else echo "OCDA-READ DIFFERS $stem"
+ fi
done
echo
echo "documents read: $n"
echo "all four dumps identical $same"
+echo "ocda-read, all four identical $read_same"
diff --git a/pipeline/run.sh b/pipeline/run.sh
index 811514e..f68c906 100755
--- a/pipeline/run.sh
+++ b/pipeline/run.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env sh
# The whole pipeline: build, read, write, typeset.
#
# ARTEFACTS=<dir of .ssp and .ocda.db> OUT=<dir> sh pipeline/run.sh
diff --git a/pipeline/write.sh b/pipeline/write.sh
index 7e1bead..aeb1f18 100755
--- a/pipeline/write.sh
+++ b/pipeline/write.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env sh
# Every writer, in both languages, over every document, into $OUT/write/.
#
# write/text/{d,g}/<doc>.txt