#!/usr/bin/env bash set -euo pipefail root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)" source_json="$root/json/card_source.json" pdf="$root/doc/pdf/mpabi-inf-c-12-uart-polling-interrupts-v00.01-e766c4bb-2a43-5f4e-b10a-b3393a42932c.pdf" jq -e '(.tasks | length) == 3 and ([.tasks[].viewpoints | map(.id)] | all(. == ["A1","A2","A3","A4","A5","A6","A7","A8"]))' \ "$source_json" >/dev/null node --check "$root/web/app.js" node -e 'JSON.parse(require("fs").readFileSync(process.argv[1], "utf8"))' \ "$root/web/card-data.json" qpdf --check "$pdf" >/dev/null [[ "$(pdftotext -layout "$pdf" - | grep -Eo 'BLOCK A[1-8]' | wc -l)" -eq 24 ]] [[ "$(pdftotext -layout "$pdf" - | awk 'BEGIN {RS="\f"} /BLOCK A[1-8]/ && !/TASK0[1-3]/ {n++} END {print n+0}')" -eq 0 ]] printf 'PASS: JSON, web and PDF contain 3 x A1-A8\n'