Chris@1596
|
1 #!/bin/bash
|
Chris@1596
|
2
|
Chris@1596
|
3 # The big problem with this test script is that it needs the cron
|
Chris@1596
|
4 # scripts that generate some of this stuff to have been run at least
|
Chris@1596
|
5 # once
|
Chris@1596
|
6
|
Chris@1596
|
7 usage() {
|
Chris@1596
|
8 echo 1>&2
|
Chris@1596
|
9 echo "Usage: $0 <uri-base>" 1>&2
|
Chris@1596
|
10 echo 1>&2
|
Chris@1596
|
11 echo " e.g. $0 https://code.soundsoftware.ac.uk" 1>&2
|
Chris@1596
|
12 echo " or $0 http://localhost:8080" 1>&2
|
Chris@1596
|
13 echo 1>&2
|
Chris@1596
|
14 exit 2
|
Chris@1596
|
15 }
|
Chris@1596
|
16
|
Chris@1596
|
17 uribase="$1"
|
Chris@1596
|
18 if [ -z "$uribase" ]; then
|
Chris@1596
|
19 usage
|
Chris@1596
|
20 fi
|
Chris@1596
|
21
|
Chris@1596
|
22 set -eu
|
Chris@1596
|
23
|
Chris@1597
|
24 # A project known to exist, be public, and have a repository
|
Chris@1597
|
25 project_with_repo=vamp-plugin-sdk
|
Chris@1597
|
26
|
Chris@1597
|
27 # A project known to exist, be public, and have embedded documentation
|
Chris@1597
|
28 project_with_docs=vamp-plugin-sdk
|
Chris@1597
|
29
|
Chris@1597
|
30 # A project known to exist, be public, and have a bibliography
|
Chris@1597
|
31 project_with_biblio=sonic-visualiser
|
Chris@1596
|
32
|
Chris@1612
|
33 # A project known not to exist
|
Chris@1612
|
34 nonexistent_project=nonexistent-project
|
Chris@1612
|
35
|
Chris@1613
|
36 # A file for download known to exist
|
Chris@1613
|
37 file_for_download=/attachments/download/2210/vamp-plugin-sdk-2.7.1-binaries-osx.tar.gz
|
Chris@1613
|
38
|
Chris@1596
|
39 tried=0
|
Chris@1596
|
40 succeeded=0
|
Chris@1596
|
41
|
Chris@1596
|
42 mydir=$(dirname "$0")
|
Chris@1596
|
43
|
Chris@1596
|
44 try() {
|
Chris@1596
|
45 mkdir -p "$mydir/output"
|
Chris@1596
|
46 origin=$(pwd)
|
Chris@1596
|
47 cd "$mydir/output"
|
Chris@1596
|
48 path="$1"
|
Chris@1596
|
49 description="$2"
|
Chris@1612
|
50 expected="$3"
|
Chris@1596
|
51 url="$uribase$path"
|
Chris@1596
|
52 echo
|
Chris@1596
|
53 echo "Trying \"$description\" [$url]..."
|
Chris@1596
|
54 echo
|
Chris@1596
|
55 if wget "$url" ; then
|
Chris@1596
|
56 echo "+++ Succeeded"
|
Chris@1596
|
57 succeeded=$(($succeeded + 1))
|
Chris@1596
|
58 else
|
Chris@1612
|
59 returned="$?"
|
Chris@1612
|
60 if [ "$returned" = "$expected" ]; then
|
Chris@1612
|
61 echo "+++ Succeeded [returned expected code $expected]"
|
Chris@1612
|
62 succeeded=$(($succeeded + 1))
|
Chris@1612
|
63 else
|
Chris@1612
|
64 echo "--- FAILED with return code $returned"
|
Chris@1612
|
65 fi
|
Chris@1596
|
66 fi
|
Chris@1597
|
67 tried=$(($tried + 1))
|
Chris@1597
|
68 cd "$origin"
|
Chris@1596
|
69 }
|
Chris@1596
|
70
|
Chris@1612
|
71 assert() {
|
Chris@1612
|
72 try "$1" "$2" 0
|
Chris@1612
|
73 }
|
Chris@1612
|
74
|
Chris@1612
|
75 fail() {
|
Chris@1612
|
76 try "$1" "$2" "$3"
|
Chris@1612
|
77 }
|
Chris@1612
|
78
|
Chris@1612
|
79 assert "/" "Front page"
|
Chris@1612
|
80 assert "/projects/$project_with_repo" "Project page"
|
Chris@1612
|
81 assert "/projects/$project_with_biblio" "Project page with bibliography"
|
Chris@1612
|
82 assert "/projects/$project_with_repo/repository" "Repository page"
|
Chris@1612
|
83 assert "/hg/$project_with_repo" "Mercurial repo"
|
Chris@1612
|
84 assert "/projects/$project_with_docs/embedded" "Project documentation page (from docgen cron script)"
|
Chris@1612
|
85 assert "/git/$project_with_repo/info/refs" "Git repo mirror"
|
Chris@1613
|
86 assert "$file_for_download" "File for download"
|
Chris@1612
|
87
|
Chris@1612
|
88 # we expect this to return an http auth requirement, not a 404 - the
|
Chris@1612
|
89 # value 6 is wget's return code for auth failure
|
Chris@1612
|
90 fail "/hg/$nonexistent_project" "Mercurial repo" 6
|
Chris@1596
|
91
|
Chris@1596
|
92 echo
|
Chris@1596
|
93 echo "Passed $succeeded of $tried"
|
Chris@1596
|
94 echo
|
Chris@1596
|
95
|