50 lines
1.5 KiB
Bash
Executable File
50 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
tmp_dir="$(mktemp -d /tmp/c11-card.XXXXXX)"
|
|
cleanup() {
|
|
rm -rf -- "$tmp_dir"
|
|
}
|
|
trap cleanup EXIT HUP INT TERM
|
|
|
|
"$root/scripts/render_card_layouts.sh" >/dev/null
|
|
"$root/scripts/render_new_pdf.sh" >/dev/null
|
|
|
|
pdf="$(find "$root/doc/pdf" -maxdepth 1 -type f \
|
|
-name 'mpabi-inf-c-11-machine-timer-*.pdf' -print -quit)"
|
|
test -n "$pdf"
|
|
qpdf --check "$pdf" >/dev/null
|
|
pdftotext -layout "$pdf" "$tmp_dir/card.txt"
|
|
|
|
blocks="$(rg -o 'A[1-8] (CONTEXT|STRUCTURE|DISPATCH|APPLICATION|FLOW|STATE|RUNTIME|PATTERNS)' \
|
|
"$tmp_dir/card.txt" | wc -l)"
|
|
test "$blocks" -eq 24
|
|
|
|
if awk 'BEGIN { RS="\f" } { compact=$0; gsub(/[[:space:]]/, "", compact); if (length(compact) < 100) exit 1 }' \
|
|
"$tmp_dir/card.txt"; then
|
|
:
|
|
else
|
|
echo "FAIL: empty or nearly empty PDF page" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if awk 'BEGIN { RS="\f" } \
|
|
/A[1-8] (CONTEXT|STRUCTURE|DISPATCH|APPLICATION|FLOW|STATE|RUNTIME|PATTERNS)/ && !/TASK0[1-3]/ { exit 1 }' \
|
|
"$tmp_dir/card.txt"; then
|
|
:
|
|
else
|
|
echo "FAIL: A1-A8 block on a page without its TASK heading" >&2
|
|
exit 1
|
|
fi
|
|
|
|
jq -e '
|
|
.tasks_order == ["task01", "task02", "task03"] and
|
|
all(.tasks[];
|
|
[.viewpoints[].id] == ["A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8"] and
|
|
all(.viewpoints[]; .status == "enabled" or .status == "unavailable"))
|
|
' "$root/json/card_source.json" >/dev/null
|
|
node --check "$root/web/app.js"
|
|
|
|
printf 'PASS card: 3 tasks, 24 A blocks, valid PDF, no empty/anonymous page\n'
|