#!/bin/sh # Runs the tidy checker over one page of most kinds cgit renders, caring only # about the shape of the markup. What the pages say is the business of the # t01xx scripts. Tidy is optional and old versions predate the elements cgit # uses, so the file steps aside when a usable one cannot be found. test_description='Validate html with tidy' . ./setup.sh # Tidy reads what it is given as a whole document, so the response headers are # dropped before it sees the page, and an empty page would only draw warnings. # Tidy leaves with 1 for warnings and 2 for errors, and only an error is worth # failing the test over. tidy_page() { strip_headers <"$1.out" >"$1" && test -s "$1" || return 1 tidy -eq "$1" test $? != 2 } # Validates the page at the url given, which has to render whole, through a # config named second for the pages the shared config keeps turned off. test_url() { tidy_file=tidy-$(printf '%s' "${1:-index}" | tr / -) && if test -n "$2" then cgit_ok "$2" "url=$1" else cgit_ok_url "$1" fi >"$tidy_file.out" && tidy_page "$tidy_file" } # Releases of tidy that predate HTML5 reject the semantic elements cgit emits, # header, nav, main and footer among them, reporting each as an error, so only # a tidy new enough to understand them will do. test_lazy_prereq TIDY ' cat >probe.html <<-\EOF &&