summaryrefslogtreecommitdiff
path: root/test/hg-web
diff options
context:
space:
mode:
Diffstat (limited to 'test/hg-web')
-rwxr-xr-xtest/hg-web89
1 files changed, 89 insertions, 0 deletions
diff --git a/test/hg-web b/test/hg-web
new file mode 100755
index 0000000..b70dfe0
--- /dev/null
+++ b/test/hg-web
@@ -0,0 +1,89 @@
+#!/bin/sh
+
+# Copyright 2017 Bob Proulx <bob@proulx.com>
+# You may freely use, modify and/or distribute this file.
+
+# Ensure a standard behavior regardless of caller locale setting.
+export LC_ALL=C
+
+unset tmpdir
+cleanup() {
+ test -n "$tmpdir" && rm -rf "$tmpdir" && unset tmpdir
+}
+trap "cleanup" EXIT
+trap "cleanup; trap - HUP; kill -HUP $$" HUP
+trap "cleanup; trap - INT; kill -INT $$" INT
+trap "cleanup; trap - QUIT; kill -QUIT $$" QUIT
+trap "cleanup; trap - TERM; kill -TERM $$" TERM
+
+tmpdir=$(mktemp -d -t "sv-test.XXXXXXXX") || exit 1
+
+cd "$tmpdir" || exit 1
+
+testit() {
+ url=$1 ; shift
+ wget -Oout "$url"
+ if [ $? -ne 0 ]; then
+ echo "Failed to web GET: $url"
+ exit 1
+ fi
+ test -s out || exit 1
+ rm -f out
+ test -s out && exit 1
+}
+
+testitxfail() {
+ url=$1 ; shift
+ wget -Oout "$url"
+ if [ $? -eq 0 ]; then
+ echo "Worked to web GET: $url"
+ exit 1
+ fi
+ test -s out && exit 1
+ echo "XFAIL: $url"
+}
+
+HGPROJ=${HGPROJ:-test-project}
+
+list="
+//hg.savannah.gnu.org/hgweb/${HGPROJ}/
+//hg.savannah.nongnu.org/hgweb/${HGPROJ}/
+//hg.sv.gnu.org/hgweb/${HGPROJ}/
+//hg.sv.nongnu.org/hgweb/${HGPROJ}/
+"
+for url in $list; do
+ testit "https:$url"
+done
+for url in $list; do
+ testit "http:$url"
+done
+
+testrobots() {
+ url=$1 ; shift
+ wget -Oout "$url"
+ fail=false
+ if [ $? -ne 0 ]; then
+ echo "Failed to web GET: $url"
+ fail=true
+ fi
+ test -s out || fail=true
+ grep ^User-agent: out || fail=true
+ grep ^Disallow: out || fail=true
+ rm -f out
+ test -s out && fail=true
+ $fail && exit 1
+}
+
+testrobots https://hg.savannah.gnu.org/robots.txt
+testrobots https://hg.savannah.nongnu.org/robots.txt
+
+testrobots https://hg.sv.gnu.org/robots.txt
+testrobots https://hg.sv.nongnu.org/robots.txt
+
+testrobots http://hg.savannah.gnu.org/robots.txt
+testrobots http://hg.savannah.nongnu.org/robots.txt
+
+testrobots http://hg.sv.gnu.org/robots.txt
+testrobots http://hg.sv.nongnu.org/robots.txt
+
+exit 0