Files
LithosAnanke/scripts/test_check_no_patent.sh
T
Claude 0234dc6baf site, docs: Downloads and Documents with every document and the nightly; never the patent (#191)
The documents stage builds the SSRN paper, experiments, proofs and the
four TeX experiment reports (from their sources), and refuses the
patent (scripts/check_no_patent.sh, by name or PDF title: test failed
first, 5 cases pass); a release and the Nexus publish check again.
texlive-science added to make init's documents (siunitx). The canvas's
Documents gains the seven, Downloads a nightly section from Nexus's
latest snapshot (build.py). Built in a scratch copy: every link and
sum filled, no patent. Left: Nexus's anonymous read, on the server.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
2026-11-21 02:59:23 +00:00

37 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# SPDX-License-Identifier: LicenseRef-Starship-1.0
# Copyright (c) 2023-2026 Robert A. James
# test_check_no_patent.sh -- the tests of scripts/check_no_patent.sh (#191: "the SSRN paper but not the
# patent"): a directory of documents is refused if any file is the patent -- named for it, or a PDF whose
# title says it is -- and passed otherwise. PDFs made here with pdflatex, from a line of TeX each.
#
# Prints PASS:/FAIL: per check and RESULT:; exits 0 only if every check passes.
set -uo pipefail
CHECK="$(cd "$(dirname "$0")" && pwd)/check_no_patent.sh"
T=$(mktemp -d)
trap 'rm -rf "$T"' EXIT
ok=1
pdf() { # pdf <dir> <name> <title>
mkdir -p "$1"
printf '\\documentclass{article}\\title{%s}\\usepackage{hyperref}\\hypersetup{pdftitle={%s}}\\begin{document}x\\end{document}\n' "$3" "$3" > "$T/t.tex"
(cd "$T" && pdflatex -interaction=nonstopmode -halt-on-error t.tex > /dev/null 2>&1) && mv "$T/t.pdf" "$1/$2"
}
expect() { # expect <pass|refuse> <dir> "what"
local out rc
out=$(bash "$CHECK" "$2" 2>&1); rc=$?
if { [ "$1" = pass ] && [ $rc -eq 0 ]; } || { [ "$1" = refuse ] && [ $rc -eq 1 ] && grep -q "refused" <<<"$out"; }; then
echo "PASS: $3"; else echo "FAIL: $3 (exit $rc: $out)"; ok=0; fi
}
pdf "$T/good" book.pdf "LithosAnanke"
pdf "$T/good" ssrn.pdf "Steady-State Machines: a paper"
expect pass "$T/good" "the book and the SSRN paper: passed"
pdf "$T/named" patent.pdf "Something"
expect refuse "$T/named" "a file named for the patent: refused"
pdf "$T/titled" vol9.pdf "Steady-State Machine --- Patent Application"
expect refuse "$T/titled" "a PDF titled as the patent, under another name: refused"
mkdir -p "$T/empty"
expect pass "$T/empty" "an empty directory: passed"
expect refuse "$T/missing" "a directory that is not there: refused, not passed by default"
echo "RESULT: $([ $ok = 1 ] && echo PASS || echo FAIL)"
[ $ok = 1 ]