81 lines
2.8 KiB
Bash
Executable File
81 lines
2.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
pdf_count="$(find "$root/doc/pdf" -maxdepth 1 -type f -name '*.pdf' | wc -l)"
|
|
[[ "$pdf_count" -eq 1 ]]
|
|
|
|
python3 - "$root/json/card_source.json" "$root/web/card-data.json" <<'PY'
|
|
import json
|
|
import sys
|
|
|
|
with open(sys.argv[1], encoding="utf-8") as stream:
|
|
card = json.load(stream)
|
|
with open(sys.argv[2], encoding="utf-8") as stream:
|
|
web = json.load(stream)
|
|
|
|
assert card["tasks_order"] == [f"task{number:02d}" for number in range(1, 6)]
|
|
blocks = []
|
|
flow_ids = []
|
|
for task_id in card["tasks_order"]:
|
|
task = card["tasks"][task_id]
|
|
viewpoints = task["viewpoints"]
|
|
assert [item["id"] for item in viewpoints] == [f"A{number}" for number in range(1, 9)]
|
|
assert len(viewpoints) == 8
|
|
assert all(item["status"] in {"enabled", "unavailable"} for item in viewpoints)
|
|
assert all(item.get("id") for item in task["flow"])
|
|
flow_ids.extend(item["id"] for item in task["flow"])
|
|
blocks.extend(item for item in task["flow"] if item["id"].startswith(task_id + ".a"))
|
|
assert len(blocks) == 40
|
|
assert len(flow_ids) == len(set(flow_ids))
|
|
task02_proof = next(
|
|
item for item in card["tasks"]["task02"]["flow"]
|
|
if item["id"] == "task02.proof"
|
|
)
|
|
assert "programu hostowego" not in task02_proof["evidence_tex"]
|
|
assert "brakująca nazwa" in task02_proof["evidence_tex"]
|
|
|
|
def viewpoint_ids(value):
|
|
if isinstance(value, dict):
|
|
identifier = value.get("id")
|
|
if isinstance(identifier, str) and identifier.rsplit(".", 1)[-1] in {
|
|
f"a{number}" for number in range(1, 9)
|
|
}:
|
|
yield identifier
|
|
for child in value.values():
|
|
yield from viewpoint_ids(child)
|
|
elif isinstance(value, list):
|
|
for child in value:
|
|
yield from viewpoint_ids(child)
|
|
|
|
web_ids = list(viewpoint_ids(web))
|
|
assert len(web_ids) == 40
|
|
assert len(set(web_ids)) == 40
|
|
print("PASS card JSON: 5 tasks x exact A1-A8 = 40 viewpoint blocks")
|
|
PY
|
|
|
|
tex_viewpoints="$(rg -o '\\begin\{ESCBlockFrame\}\{A[1-8] ' \
|
|
"$root/doc/generated/main.tex" | wc -l)"
|
|
[[ "$tex_viewpoints" -eq 40 ]]
|
|
for viewpoint in {1..8}; do
|
|
count="$(rg -o "\\\\begin\\{ESCBlockFrame\\}\\{A${viewpoint} " \
|
|
"$root/doc/generated/main.tex" | wc -l)"
|
|
[[ "$count" -eq 5 ]]
|
|
done
|
|
|
|
tex_count="$(rg -o '\\textbf\{N/D\.\}' "$root/doc/generated/main.tex" | wc -l)"
|
|
[[ "$tex_count" -ge 6 ]]
|
|
qpdf --check "$root"/doc/pdf/*.pdf
|
|
rg -q 'task02\.a6' "$root/json/card_source.json"
|
|
|
|
pdf_text="$(mktemp)"
|
|
trap 'rm -f -- "$pdf_text"' EXIT
|
|
pdftotext "$root"/doc/pdf/*.pdf "$pdf_text"
|
|
pdf_viewpoints="$(rg -o 'BLOCK A[1-8]' "$pdf_text" | wc -l)"
|
|
[[ "$pdf_viewpoints" -eq 40 ]]
|
|
if rg -qi 'anonymous|anonimowy|bez nazwy' "$pdf_text"; then
|
|
echo 'FAIL card: anonymous block marker found' >&2
|
|
exit 1
|
|
fi
|
|
printf 'PASS card artifacts: TeX, web and one valid PDF\n'
|