Add test suite, README and .gitignore rules; untrack LibreOffice locks
Why: the repository was reported as a 328 MB LaTeX collection, which is a red flag for a text project. The weight map shows the bulk is real content -- literature PDFs (169 MB), slide decks (92 MB) and figures (62 MB) -- and the only build leftovers ever committed were two empty LibreOffice lock files. So: audit the tree, prove the documents compile, and leave an automated check behind so later edits cannot quietly break them. - Untrack thesis/.~lock.thesis.pptx# and thesis/.~lock.thesis-arch.pptx# (2 files, 132 bytes; the files stay on disk). The checkout loses 233 bytes of 666 MB: there was no junk to remove. - .gitignore: the full LaTeX build-product set (adds .lof/.lot/.nav/.snm/.vrb/ .run.xml/.dvi/... to the existing rules) plus OS, editor and office leftovers. - tests/: `make test` compiles the five main documents with latexmk and checks page counts, fatal errors, unresolved references and citations, missing input files, every \includegraphics on disk and every \cite key against the .bib; eight negative and control checks; non-zero exit when a check fails. - README.md: what the three folders are, the weight map and largest files, the duplicated trees and the stray LNCS sample left in place, the real build commands, the test output, and why no licence is applied. Compilation verified on TeX Live 2025 on the Pi 5. Missing packages installed: biber, texlive-lang-portuguese and texlive-publishers -- without splncs04.bst from the last one both IBPria papers keep 63 undefined citations and latexmk exits 12. No text, figure or bibliography content was changed.
This commit is contained in:
Executable
+329
@@ -0,0 +1,329 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Checks for the master-thesis LaTeX collection (see README.md, "Tests").
|
||||
|
||||
Sub-commands
|
||||
------------
|
||||
static <project-dir> <main.tex>
|
||||
Follows the \\input/\\include tree of <main.tex> and checks, from the
|
||||
sources alone:
|
||||
* every \\includegraphics argument resolves to a file on disk;
|
||||
* every \\cite key has an entry in the project's .bib file.
|
||||
Unused .bib entries are reported but never fail the run.
|
||||
|
||||
build <project-dir> <main.tex> <expected-pages> [outdir]
|
||||
Runs `latexmk -pdf` (output to <outdir>, or a fresh temporary directory)
|
||||
and checks the PDF exists, has exactly <expected-pages> pages, and that
|
||||
the final pass reports no fatal error, no unresolved reference, no
|
||||
unresolved citation and no missing input file. Overfull/underfull boxes
|
||||
are reported as information.
|
||||
|
||||
usedkeys <project-dir> <main.tex> one cited key per line
|
||||
drop-entry <bib-file> <key> removes one entry from a .bib file
|
||||
inject-graphic <main.tex> <path> inserts \\includegraphics{<path>} before \\end{document}
|
||||
|
||||
Exit status is 0 only when every check of the sub-command passed.
|
||||
"""
|
||||
|
||||
import glob
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
CITE_RE = re.compile(
|
||||
r"\\(?:cite|citep|citet|citealp|citeauthor|citeyear|Cite|parencite|textcite"
|
||||
r"|autocite|footcite|smartcite|nocite)\*?(?:\[[^\]]*\])*\s*\{([^}]*)\}"
|
||||
)
|
||||
GRAPHICS_RE = re.compile(r"\\includegraphics\s*(?:\[[^\]]*\])?\s*\{([^}]*)\}")
|
||||
INPUT_RE = re.compile(r"\\(?:input|include)\s*\{([^}]*)\}")
|
||||
ADDBIB_RE = re.compile(r"\\addbibresource(?:\[[^\]]*\])?\s*\{([^}]*)\}")
|
||||
BIBLIO_RE = re.compile(r"\\bibliography\s*\{([^}]*)\}")
|
||||
ENTRY_RE = re.compile(r"@\w+\s*\{\s*([^,\s]+)\s*,")
|
||||
GRAPHIC_EXTS = ("", ".pdf", ".png", ".jpg", ".jpeg", ".eps", ".ps", ".PNG", ".JPG")
|
||||
|
||||
|
||||
def fail(msg):
|
||||
print(" FAIL: " + msg)
|
||||
|
||||
|
||||
def note(msg):
|
||||
print(" note: " + msg)
|
||||
|
||||
|
||||
def strip_comments(text):
|
||||
out = []
|
||||
for line in text.splitlines():
|
||||
res, i = "", 0
|
||||
while i < len(line):
|
||||
if line[i] == "%" and (i == 0 or line[i - 1] != "\\"):
|
||||
break
|
||||
res += line[i]
|
||||
i += 1
|
||||
out.append(res)
|
||||
return "\n".join(out)
|
||||
|
||||
|
||||
def read(path):
|
||||
with open(path, encoding="utf-8", errors="replace") as fh:
|
||||
return strip_comments(fh.read())
|
||||
|
||||
|
||||
def input_tree(project, main):
|
||||
"""All .tex reachable from <main> through \\input/\\include (LaTeX order)."""
|
||||
seen, order = set(), []
|
||||
|
||||
def walk(rel):
|
||||
path = os.path.join(project, rel)
|
||||
if not os.path.isfile(path) or os.path.abspath(path) in seen:
|
||||
return
|
||||
seen.add(os.path.abspath(path))
|
||||
order.append(rel)
|
||||
text = read(path)
|
||||
for raw in INPUT_RE.findall(text):
|
||||
target = raw.strip()
|
||||
if not target or "\\" in target: # macro or \input{|cmd}
|
||||
continue
|
||||
if not os.path.splitext(target)[1]:
|
||||
target += ".tex"
|
||||
walk(target)
|
||||
|
||||
walk(main)
|
||||
return order
|
||||
|
||||
|
||||
def bib_entries(project, rel_files):
|
||||
"""{key: (bib file, index)} for every entry of the project's .bib files."""
|
||||
entries, files = {}, []
|
||||
for rel in rel_files:
|
||||
text = read(os.path.join(project, rel))
|
||||
for bib in ADDBIB_RE.findall(text) + BIBLIO_RE.findall(text):
|
||||
for name in bib.split(","):
|
||||
name = name.strip()
|
||||
if not name:
|
||||
continue
|
||||
name = name if name.endswith(".bib") else name + ".bib"
|
||||
if name not in files:
|
||||
files.append(name)
|
||||
for name in files:
|
||||
path = os.path.join(project, name)
|
||||
if not os.path.isfile(path):
|
||||
fail("declared bibliography %s does not exist" % name)
|
||||
continue
|
||||
raw = open(path, encoding="utf-8", errors="replace").read()
|
||||
for m in ENTRY_RE.finditer(raw):
|
||||
entries.setdefault(m.group(1).strip(), (name, raw))
|
||||
return entries, files
|
||||
|
||||
|
||||
def check_static(project, main, quiet_ok=False):
|
||||
project = os.path.abspath(project)
|
||||
rels = input_tree(project, main)
|
||||
failures = 0
|
||||
|
||||
if not rels:
|
||||
fail("main file %s not found under %s" % (main, project))
|
||||
return 1
|
||||
|
||||
print(" input tree: %d .tex files (%s)" % (len(rels), ", ".join(rels[:6]) +
|
||||
(", ..." if len(rels) > 6 else "")))
|
||||
|
||||
# ---- figures -------------------------------------------------------
|
||||
total = missing = 0
|
||||
missing_list = []
|
||||
for rel in rels:
|
||||
for raw in GRAPHICS_RE.findall(read(os.path.join(project, rel))):
|
||||
name = raw.strip()
|
||||
if not name or "\\" in name:
|
||||
continue
|
||||
total += 1
|
||||
base = os.path.join(project, name)
|
||||
candidates = [base + e for e in GRAPHIC_EXTS]
|
||||
if not any(os.path.isfile(c) for c in candidates):
|
||||
missing += 1
|
||||
missing_list.append("%s -> %s" % (rel, name))
|
||||
if missing:
|
||||
failures += 1
|
||||
fail("%d of %d \\includegraphics do not exist on disk" % (missing, total))
|
||||
for item in missing_list[:10]:
|
||||
print(" " + item)
|
||||
if len(missing_list) > 10:
|
||||
print(" ... and %d more" % (len(missing_list) - 10))
|
||||
elif not quiet_ok:
|
||||
print(" figures: %d/%d \\includegraphics resolve" % (total - missing, total))
|
||||
|
||||
# ---- citations -----------------------------------------------------
|
||||
used = set()
|
||||
for rel in rels:
|
||||
for field in CITE_RE.findall(read(os.path.join(project, rel))):
|
||||
for key in field.split(","):
|
||||
key = key.strip()
|
||||
if key and key != "*":
|
||||
used.add(key)
|
||||
entries, bibfiles = bib_entries(project, rels)
|
||||
absent, unused = [], []
|
||||
if not bibfiles:
|
||||
if used:
|
||||
failures += 1
|
||||
fail("%d citation keys but no .bib is declared by the main tree" % len(used))
|
||||
else:
|
||||
note("no bibliography declared and no citations used")
|
||||
else:
|
||||
absent = sorted(k for k in used if k not in entries)
|
||||
if absent:
|
||||
failures += 1
|
||||
fail("%d \\cite keys have no entry in %s: %s"
|
||||
% (len(absent), ", ".join(bibfiles), ", ".join(absent[:8])))
|
||||
else:
|
||||
print(" citations: %d/%d \\cite keys found in %s"
|
||||
% (len(used), len(used), ", ".join(bibfiles)))
|
||||
unused = sorted(k for k in entries if k not in used)
|
||||
if unused:
|
||||
note("%d .bib entries are never cited (reported, not a failure): %s%s"
|
||||
% (len(unused), ", ".join(unused[:8]), " ..." if len(unused) > 8 else ""))
|
||||
|
||||
# ---- stray .tex files (not part of the main tree) -------------------
|
||||
on_disk = {os.path.relpath(p, project) for p in
|
||||
glob.glob(os.path.join(project, "**", "*.tex"), recursive=True)}
|
||||
stray = sorted(on_disk - set(rels))
|
||||
if stray:
|
||||
note("not reachable from %s (ignored by these checks): %s"
|
||||
% (main, ", ".join(stray)))
|
||||
|
||||
print(" summary: figures=%d figures_missing=%d cites=%d cites_missing=%d "
|
||||
"bib_entries=%d bib_unused=%d"
|
||||
% (total, missing, len(used), len(absent), len(entries), len(unused)))
|
||||
return failures
|
||||
|
||||
|
||||
def check_build(project, main, expected_pages, outdir=None):
|
||||
project = os.path.abspath(project)
|
||||
failures = 0
|
||||
temp = None
|
||||
if outdir is None:
|
||||
temp = tempfile.mkdtemp(prefix="master-thesis-build-")
|
||||
outdir = temp
|
||||
os.makedirs(outdir, exist_ok=True)
|
||||
stem = os.path.splitext(os.path.basename(main))[0]
|
||||
log_path, pdf_path = os.path.join(outdir, stem + ".log"), os.path.join(outdir, stem + ".pdf")
|
||||
|
||||
cmd = ["latexmk", "-pdf", "-interaction=nonstopmode", "-file-line-error",
|
||||
"-outdir=" + outdir, main]
|
||||
print(" $ (cd %s && %s)" % (os.path.relpath(project), " ".join(cmd)))
|
||||
proc = subprocess.run(cmd, cwd=project, capture_output=True, text=True,
|
||||
encoding="utf-8", errors="replace")
|
||||
out = proc.stdout + proc.stderr
|
||||
if proc.returncode != 0:
|
||||
failures += 1
|
||||
fail("latexmk exited %d" % proc.returncode)
|
||||
for line in out.splitlines():
|
||||
if line.startswith("Latexmk:") and ("rror" in line or "ailed" in line):
|
||||
print(" " + line.strip())
|
||||
if not os.path.isfile(pdf_path):
|
||||
failures += 1
|
||||
fail("no PDF produced at %s" % pdf_path)
|
||||
print(" summary: pages=0/%d unresolved_refs=0 unresolved_cites=0 "
|
||||
"missing_files=0 fatal_errors=0 latexmk_rc=%d"
|
||||
% (expected_pages, proc.returncode))
|
||||
if temp:
|
||||
shutil.rmtree(temp, ignore_errors=True)
|
||||
return failures
|
||||
|
||||
if not os.path.isfile(log_path):
|
||||
failures += 1
|
||||
fail("no .log produced at %s" % log_path)
|
||||
return failures
|
||||
log = open(log_path, encoding="utf-8", errors="replace").read()
|
||||
|
||||
errors = re.findall(r"(?m)^! (.*)$", log)
|
||||
if errors:
|
||||
failures += 1
|
||||
fail("%d fatal error(s) in the final pass: %s" % (len(errors), errors[0].strip()))
|
||||
missing = sorted({m for m in re.findall(r"File `([^']*)' not found", log)})
|
||||
if missing:
|
||||
failures += 1
|
||||
fail("missing input file(s): %s" % ", ".join(missing[:6]))
|
||||
undef_refs = sorted({m for m in re.findall(r"Reference `([^']*)' on page", log)})
|
||||
if undef_refs:
|
||||
failures += 1
|
||||
fail("%d unresolved reference(s): %s" % (len(undef_refs), ", ".join(undef_refs[:8])))
|
||||
undef_cites = sorted({m for m in re.findall(r"Citation `([^']*)' on page", log)})
|
||||
if undef_cites:
|
||||
failures += 1
|
||||
fail("%d unresolved citation(s): %s" % (len(undef_cites), ", ".join(undef_cites[:8])))
|
||||
|
||||
info = subprocess.run(["pdfinfo", pdf_path], capture_output=True, text=True,
|
||||
encoding="utf-8", errors="replace").stdout
|
||||
m = re.search(r"(?m)^Pages:\s+(\d+)", info)
|
||||
pages = int(m.group(1)) if m else 0
|
||||
if pages != expected_pages:
|
||||
failures += 1
|
||||
fail("PDF has %d pages, expected %d" % (pages, expected_pages))
|
||||
else:
|
||||
print(" pages: %d (expected %d), %d bytes"
|
||||
% (pages, expected_pages, os.path.getsize(pdf_path)))
|
||||
|
||||
if not errors and not missing and not undef_refs and not undef_cites:
|
||||
print(" log: 0 fatal errors, 0 unresolved references, 0 unresolved citations")
|
||||
overfull = len(re.findall(r"Overfull \\hbox", log))
|
||||
underfull = len(re.findall(r"Underfull \\hbox", log))
|
||||
note("%d overfull and %d underfull boxes (typesetting, not failures)"
|
||||
% (overfull, underfull))
|
||||
print(" summary: pages=%d/%d unresolved_refs=%d unresolved_cites=%d "
|
||||
"missing_files=%d fatal_errors=%d latexmk_rc=%d"
|
||||
% (pages, expected_pages, len(undef_refs), len(undef_cites),
|
||||
len(missing), len(errors), proc.returncode))
|
||||
return failures
|
||||
|
||||
|
||||
def main(argv):
|
||||
if len(argv) < 2:
|
||||
print(__doc__)
|
||||
return 2
|
||||
cmd = argv[1]
|
||||
if cmd == "static":
|
||||
return 1 if check_static(argv[2], argv[3] if len(argv) > 3 else "main.tex") else 0
|
||||
if cmd == "build":
|
||||
outdir = argv[5] if len(argv) > 5 else None
|
||||
bad = check_build(argv[2], argv[3], int(argv[4]), outdir)
|
||||
return 1 if bad else 0
|
||||
if cmd == "usedkeys":
|
||||
project, main = os.path.abspath(argv[2]), argv[3] if len(argv) > 3 else "main.tex"
|
||||
used = set()
|
||||
for rel in input_tree(project, main):
|
||||
for field in CITE_RE.findall(read(os.path.join(project, rel))):
|
||||
for key in field.split(","):
|
||||
key = key.strip()
|
||||
if key and key != "*":
|
||||
used.add(key)
|
||||
print("\n".join(sorted(used)))
|
||||
return 0
|
||||
if cmd == "drop-entry":
|
||||
bib, key = argv[2], argv[3]
|
||||
raw = open(bib, encoding="utf-8", errors="replace").read()
|
||||
pattern = re.compile(r"@\w+\s*\{\s*" + re.escape(key) + r"\s*,[\s\S]*?(?=\n@|\Z)")
|
||||
new, n = pattern.subn("", raw, count=1)
|
||||
if not n:
|
||||
print(" FAIL: no entry %r in %s" % (key, bib))
|
||||
return 1
|
||||
open(bib, "w", encoding="utf-8").write(new)
|
||||
print(" dropped entry %r from %s" % (key, bib))
|
||||
return 0
|
||||
if cmd == "inject-graphic":
|
||||
path, target = argv[2], argv[3]
|
||||
raw = open(path, encoding="utf-8", errors="replace").read()
|
||||
idx = raw.rfind("\\end{document}")
|
||||
if idx < 0:
|
||||
print(" FAIL: %s has no \\end{document}" % path)
|
||||
return 1
|
||||
raw = raw[:idx] + "\\includegraphics{%s}\n" % target + raw[idx:]
|
||||
open(path, "w", encoding="utf-8").write(raw)
|
||||
print(" injected \\includegraphics{%s} into %s" % (target, path))
|
||||
return 0
|
||||
print(__doc__)
|
||||
return 2
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main(sys.argv))
|
||||
@@ -0,0 +1,7 @@
|
||||
# Main documents of this repository: <directory>|<main .tex>|<pages of a fresh build>
|
||||
# Page counts are what `latexmk -pdf` produces today (see README.md, "Tests").
|
||||
thesis|main.tex|114
|
||||
papers/ibpria2025|main.tex|15
|
||||
papers/ibpria-extended2025|main.tex|15
|
||||
papers/demographic-bias|main.tex|6
|
||||
papers/on-paper-data-aug|main.tex|7
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
% Negative fixture: \cite{ghost-entry} has no entry in refs.bib.
|
||||
\documentclass{article}
|
||||
\begin{document}
|
||||
See \cite{ghost-entry} for a reference that does not exist.
|
||||
\bibliographystyle{plain}
|
||||
\bibliography{refs}
|
||||
\end{document}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
@article{knuth1984,
|
||||
author = {Knuth, Donald E.},
|
||||
title = {Literate Programming},
|
||||
journal = {The Computer Journal},
|
||||
volume = {27},
|
||||
number = {2},
|
||||
pages = {97--111},
|
||||
year = {1984}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
% Negative fixture: the figure below is not on disk, so `check.py static`
|
||||
% (and a latexmk build of this file) must fail.
|
||||
\documentclass{article}
|
||||
\usepackage{graphicx}
|
||||
\begin{document}
|
||||
\includegraphics{images/this-file-does-not-exist.png}
|
||||
\end{document}
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
% Control fixture: one citation that exists in refs.bib, no figures.
|
||||
% Both `check.py static` and `check.py build` must pass on this file.
|
||||
\documentclass{article}
|
||||
\begin{document}
|
||||
See \cite{knuth1984}.
|
||||
\bibliographystyle{plain}
|
||||
\bibliography{refs}
|
||||
\end{document}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
@article{knuth1984,
|
||||
author = {Knuth, Donald E.},
|
||||
title = {Literate Programming},
|
||||
journal = {The Computer Journal},
|
||||
volume = {27},
|
||||
number = {2},
|
||||
pages = {97--111},
|
||||
year = {1984}
|
||||
}
|
||||
Executable
+149
@@ -0,0 +1,149 @@
|
||||
#!/usr/bin/env bash
|
||||
# Test suite for the master-thesis LaTeX collection. See README.md, "Tests".
|
||||
#
|
||||
# tests/run.sh compile every main document and check it (slow)
|
||||
# tests/run.sh static sources only, no compilation (fast)
|
||||
#
|
||||
# Exits non-zero if any check fails.
|
||||
|
||||
set -u
|
||||
|
||||
ROOT=$(cd "$(dirname "$0")/.." && pwd)
|
||||
CHECK="$ROOT/tests/check.py"
|
||||
CONF="$ROOT/tests/documents.conf"
|
||||
MODE="${1:-full}"
|
||||
case "$MODE" in full|static) ;; *) echo "usage: $0 [full|static]" >&2; exit 2 ;; esac
|
||||
|
||||
WORK=$(mktemp -d "${TMPDIR:-/tmp}/master-thesis-tests.XXXXXX")
|
||||
cleanup() {
|
||||
case "$WORK" in /tmp/*|"${TMPDIR:-/tmp}"/*) rm -rf "$WORK" ;; esac
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
CHECKS=0
|
||||
FAILED=0
|
||||
declare -a ROWS=()
|
||||
declare -a DOCROWS=()
|
||||
|
||||
add_row() { # name | expectation | actual | ok
|
||||
ROWS+=("| $1 | $2 | $3 | $4 |")
|
||||
CHECKS=$((CHECKS + 1))
|
||||
[ "$4" = "yes" ] || FAILED=$((FAILED + 1))
|
||||
}
|
||||
add_doc() { # document | pages want/got | static | build | unresolved | result
|
||||
DOCROWS+=("| $1 | $2 | $3 | $4 | $5 | $6 |")
|
||||
CHECKS=$((CHECKS + 1))
|
||||
[ "$6" = "PASS" ] || FAILED=$((FAILED + 1))
|
||||
}
|
||||
summary() { sed -n 's/^ summary: //p' <<<"$1" | tail -1; }
|
||||
|
||||
echo "== master-thesis test suite =="
|
||||
echo "root: $ROOT"
|
||||
echo "mode: $MODE ($([ "$MODE" = full ] && echo 'compile + sources' || echo 'sources only'))"
|
||||
echo "tex: $(pdflatex --version 2>/dev/null | head -1)"
|
||||
echo "tool: $(latexmk -v 2>/dev/null | head -1)"
|
||||
echo
|
||||
echo "-- main documents --"
|
||||
|
||||
while IFS='|' read -r dir main pages; do
|
||||
case "$dir" in ''|'#'*) continue ;; esac
|
||||
doc="$dir/$main"
|
||||
echo "### $doc"
|
||||
|
||||
out=$("$CHECK" static "$ROOT/$dir" "$main" 2>&1); rc=$?
|
||||
ssum=$(summary "$out")
|
||||
echo "$out" | sed 's/^/ /'
|
||||
[ "$rc" = 0 ] && static="ok" || static="FAIL"
|
||||
|
||||
build="n/a"; usum="n/a"; got="$pages"
|
||||
if [ "$MODE" = full ]; then
|
||||
out=$("$CHECK" build "$ROOT/$dir" "$main" "$pages" "$WORK/build/$dir" 2>&1); rc=$?
|
||||
echo "$out" | sed 's/^/ /'
|
||||
bsum=$(summary "$out")
|
||||
[ "$rc" = 0 ] && build="ok" || build="FAIL"
|
||||
got=$(sed -n 's/.*pages=\([0-9]*\)\/.*/\1/p' <<<"$bsum" | tail -1)
|
||||
[ -n "$got" ] || got="?"
|
||||
refs=$(sed -n 's/.*unresolved_refs=\([0-9]*\).*/\1/p' <<<"$bsum" | tail -1)
|
||||
cits=$(sed -n 's/.*unresolved_cites=\([0-9]*\).*/\1/p' <<<"$bsum" | tail -1)
|
||||
usum="refs ${refs:-?}/cites ${cits:-?} unresolved"
|
||||
fi
|
||||
|
||||
if [ "$static" = ok ] && { [ "$MODE" = static ] || [ "$build" = ok ]; }; then res="PASS"; else res="FAIL"; fi
|
||||
add_doc "\`$doc\`" "${pages} -> ${got}" "$static" "$build" "$usum" "$res"
|
||||
done < "$CONF"
|
||||
|
||||
echo
|
||||
echo "-- negative and control checks --"
|
||||
|
||||
run_negative() { # name | expectation | command...
|
||||
local name="$1" expect="$2"; shift 2
|
||||
local out rc
|
||||
out=$("$@" 2>&1); rc=$?
|
||||
local actual ok
|
||||
if [ "$rc" != 0 ]; then actual="failed (exit $rc)"; else actual="passed (exit 0)"; fi
|
||||
if [[ "$expect" == *"must fail"* ]]; then
|
||||
ok=$([ "$rc" != 0 ] && echo yes || echo no)
|
||||
else
|
||||
ok=$([ "$rc" = 0 ] && echo yes || echo no)
|
||||
fi
|
||||
add_row "$name" "$expect" "$actual" "$ok"
|
||||
if [ "$ok" = no ]; then echo " --- output of the failing check ---"; echo "$out" | sed 's/^/ /'; fi
|
||||
}
|
||||
|
||||
run_negative "fixture: figure points at a file that does not exist" "static must fail" \
|
||||
"$CHECK" static "$ROOT/tests/fixtures/missing-figure" main.tex
|
||||
run_negative "fixture: citation with no .bib entry" "static must fail" \
|
||||
"$CHECK" static "$ROOT/tests/fixtures/missing-cite" main.tex
|
||||
run_negative "fixture: clean document (control)" "static must pass" \
|
||||
"$CHECK" static "$ROOT/tests/fixtures/ok" main.tex
|
||||
run_negative "fixture: clean document compiles (control)" "build must pass" \
|
||||
"$CHECK" build "$ROOT/tests/fixtures/ok" main.tex 1 "$WORK/build/fixture-ok"
|
||||
run_negative "fixture: wrong expected page count" "build must fail" \
|
||||
"$CHECK" build "$ROOT/tests/fixtures/ok" main.tex 99 "$WORK/build/fixture-pages"
|
||||
|
||||
# A used .bib entry removed from a copy of the real thesis sources.
|
||||
cp -r "$ROOT/thesis" "$WORK/thesis-bib" 2>/dev/null
|
||||
key=$(python3 "$CHECK" usedkeys "$ROOT/thesis" main.tex | head -1)
|
||||
if [ -n "$key" ]; then
|
||||
python3 "$CHECK" drop-entry "$WORK/thesis-bib/misc/references.bib" "$key" >/dev/null 2>&1
|
||||
fi
|
||||
out=$(python3 "$CHECK" static "$WORK/thesis-bib" main.tex 2>&1); rc=$?
|
||||
ok=no
|
||||
[ -n "$key" ] && [ "$rc" != 0 ] && ok=yes
|
||||
add_row "thesis copy: used .bib entry '$key' deleted" "static must fail" "exit $rc" "$ok"
|
||||
[ "$ok" = yes ] || { echo " --- output ---"; echo "$out" | sed 's/^/ /'; }
|
||||
|
||||
# The real thesis sources with no images on disk.
|
||||
cp -r "$ROOT/thesis" "$WORK/thesis-fig" 2>/dev/null
|
||||
rm -rf "$WORK/thesis-fig/images"
|
||||
out=$(python3 "$CHECK" static "$WORK/thesis-fig" main.tex 2>&1); rc=$?
|
||||
ok=no; [ "$rc" != 0 ] && ok=yes
|
||||
add_row "thesis copy with images/ deleted" "static must fail" "exit $rc" "$ok"
|
||||
[ "$ok" = yes ] || { echo " --- output ---"; echo "$out" | sed 's/^/ /'; }
|
||||
|
||||
if [ "$MODE" = full ]; then
|
||||
# A real paper with one extra graphic that does not exist: the build must fail.
|
||||
cp -r "$ROOT/papers/demographic-bias" "$WORK/db-bad" 2>/dev/null
|
||||
python3 "$CHECK" inject-graphic "$WORK/db-bad/main.tex" images/DOES-NOT-EXIST.png >/dev/null 2>&1
|
||||
out=$(python3 "$CHECK" build "$WORK/db-bad" main.tex 6 "$WORK/build/db-bad" 2>&1); rc=$?
|
||||
add_row "real paper + \includegraphics to a missing file" "build must fail" "exit $rc" \
|
||||
"$([ "$rc" != 0 ] && echo yes || echo no)"
|
||||
else
|
||||
echo " (compile-level negative checks skipped in static mode)"
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "-- documents --"
|
||||
echo "| document | pages (want -> got) | static | build | unresolved | result |"
|
||||
echo "|---|---|---|---|---|---|"
|
||||
printf '%s\n' "${DOCROWS[@]}"
|
||||
echo
|
||||
echo "-- checks --"
|
||||
echo "| check | expectation | actual | ok |"
|
||||
echo "|---|---|---|---|"
|
||||
printf '%s\n' "${ROWS[@]}"
|
||||
echo
|
||||
echo "checks: $CHECKS | failed: $FAILED"
|
||||
if [ "$FAILED" = 0 ]; then echo "RESULT: PASS"; else echo "RESULT: FAIL"; fi
|
||||
[ "$FAILED" = 0 ] || exit 1
|
||||
exit 0
|
||||
Reference in New Issue
Block a user