diff options
Diffstat (limited to 'tests/t0010-validate-html.sh')
| -rwxr-xr-x | tests/t0010-validate-html.sh | 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 20 insertions, 10 deletions
diff --git a/tests/t0010-validate-html.sh b/tests/t0010-validate-html.sh index 91433f8..308cef7 100755 --- a/tests/t0010-validate-html.sh +++ b/tests/t0010-validate-html.sh @@ -1,20 +1,30 @@ #!/bin/sh +# Runs the tidy checker over one page of each kind cgit renders, so that markup +# broken enough to confuse a browser is caught here rather than in the browser. +# Only the shape of the markup matters, since what the pages actually say is +# the business of the t01xx scripts. Tidy is optional and old versions of it +# predate the elements cgit uses, so the whole file steps aside when a usable +# one cannot be found. + test_description='Validate html with tidy' . ./setup.sh - test_url() { - tidy_opt="-eq" - test -z "$NO_TIDY_WARNINGS" || tidy_opt+=" --show-warnings no" + tidy_options="-eq" + test -z "$NO_TIDY_WARNINGS" || + tidy_options="$tidy_options --show-warnings no" cgit_url "$1" >tidy-$test_count.tmp || return + # Tidy reads what it is given as a whole document, so the response + # headers are dropped before it sees the page. sed -e "1,4d" tidy-$test_count.tmp >tidy-$test_count || return - "$tidy" $tidy_opt tidy-$test_count - rc=$? + "$tidy" $tidy_options tidy-$test_count + status=$? - # tidy returns with exitcode 1 on warnings, 2 on error - if test $rc = 2 + # Tidy leaves with 1 for warnings and 2 for errors, and only an error is + # worth failing the test over. + if test $status = 2 then false else @@ -22,15 +32,15 @@ test_url() fi } -tidy=`which tidy 2>/dev/null` +tidy=$(which tidy 2>/dev/null) test -n "$tidy" || { skip_all='Skipping html validation tests: tidy not found' test_done exit } -# Releases of tidy that predate HTML5 reject the semantic elements (header, -# nav, main, footer) that cgit emits, reporting them as errors. Skip the +# Releases of tidy that predate HTML5 reject the semantic elements cgit emits, +# header, nav, main and footer among them, reporting each as an error. Skip the # validation unless tidy is new enough to understand them. printf '<!DOCTYPE html>\n<html lang="en"><head><title>t</title></head><body><header>x</header></body></html>\n' \ | "$tidy" -q -e >/dev/null 2>&1 |
