summaryrefslogtreecommitdiff
path: root/test/hg-web
blob: b70dfe06896f538224e81aa51013d100682e8e1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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