/[jscoverage]/trunk/tests/server.sh
ViewVC logotype

Contents of /trunk/tests/server.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 181 - (show annotations)
Sun Sep 21 18:42:02 2008 UTC (10 years, 9 months ago) by siliconforks
File MIME type: application/x-sh
File size: 4983 byte(s)
Fix tests.

1 #!/bin/sh
2 # server.sh - test jscoverage-server
3 # Copyright (C) 2008 siliconforks.com
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
19 set -e
20
21 shutdown() {
22 wget -q -O- --post-data= "http://127.0.0.1:${server_port}/jscoverage-shutdown" > /dev/null
23 wait $server_pid
24 }
25
26 cleanup() {
27 rm -fr EXPECTED ACTUAL DIR OUT
28 # kill $server_pid
29 shutdown
30 }
31
32 trap 'cleanup' 0 1 2 3 15
33
34 export PATH=.:..:$PATH
35
36 if [ -z "$VALGRIND" ]
37 then
38 delay=0.2
39 else
40 delay=2
41 fi
42
43 rm -fr EXPECTED DIR OUT
44 mkdir DIR
45 $VALGRIND jscoverage-server --no-highlight --document-root=recursive --report-dir=DIR &
46 server_pid=$!
47 server_port=8080
48
49 sleep $delay
50
51 wget -q -O- http://127.0.0.1:8080/index.html | diff recursive/index.html -
52 wget -q -O- http://127.0.0.1:8080/style.css | diff recursive/style.css -
53 wget -q -O- http://127.0.0.1:8080/unix.txt | diff recursive/unix.txt -
54 wget -q -O- http://127.0.0.1:8080/windows.txt | diff recursive/windows.txt -
55 wget -q -O- http://127.0.0.1:8080/image.png | diff recursive/image.png -
56 wget -q -O- http://127.0.0.1:8080/1/1.html | diff recursive/1/1.html -
57 wget -q -O- http://127.0.0.1:8080/1/1.css | diff recursive/1/1.css -
58 wget -q -O- http://127.0.0.1:8080/1/2/2.html | diff recursive/1/2/2.html -
59 wget -q -O- http://127.0.0.1:8080/1/2/2.css | diff recursive/1/2/2.css -
60
61 # test query string
62 wget -q -O- http://127.0.0.1:8080/index.html?foo | diff recursive/index.html -
63
64 # test javascript
65 wget -q -O- http://127.0.0.1:8080/script.js > OUT
66 cat recursive.expected/script.js ../report.js | sed 's/@PREFIX@/\//g' | diff - OUT
67 wget -q -O- http://127.0.0.1:8080/1/1.js > OUT
68 cat recursive.expected/1/1.js ../report.js | sed 's/@PREFIX@/\//g' | diff - OUT
69 wget -q -O- http://127.0.0.1:8080/1/2/2.js > OUT
70 cat recursive.expected/1/2/2.js ../report.js | sed 's/@PREFIX@/\//g' | diff - OUT
71
72 # test jscoverage
73 wget -q -O- http://127.0.0.1:8080/jscoverage.html | diff ../jscoverage.html -
74 wget -q -O- http://127.0.0.1:8080/jscoverage.css | diff ../jscoverage.css -
75 wget -q -O- http://127.0.0.1:8080/jscoverage-throbber.gif | diff ../jscoverage-throbber.gif -
76 wget -q -O- http://127.0.0.1:8080/jscoverage.js > OUT
77 echo -e 'jscoverage_isServer = true;\r' | cat ../jscoverage.js - | diff - OUT
78
79 # load/store
80 wget --post-data='{}' -q -O- http://127.0.0.1:8080/jscoverage-store > /dev/null
81 echo -n '{}' | diff - DIR/jscoverage.json
82 diff ../jscoverage.html DIR/jscoverage.html
83 diff ../jscoverage.css DIR/jscoverage.css
84 diff ../jscoverage-throbber.gif DIR/jscoverage-throbber.gif
85 echo -e 'jscoverage_isReport = true;\r' | cat ../jscoverage.js - | diff - DIR/jscoverage.js
86
87 # 404 not found
88 echo 404 > EXPECTED
89 ! curl -f -w '%{http_code}\n' http://127.0.0.1:8080/missing 2> /dev/null > ACTUAL
90 diff EXPECTED ACTUAL
91 echo 404 > EXPECTED
92 ! curl -f -w '%{http_code}\n' http://127.0.0.1:8080/jscoverage-missing 2> /dev/null > ACTUAL
93 diff EXPECTED ACTUAL
94
95 # 403 forbidden
96 echo 403 > EXPECTED
97 ! curl -f -w '%{http_code}\n' http://127.0.0.1:8080/../Makefile.am 2> /dev/null > ACTUAL
98 diff EXPECTED ACTUAL
99
100 ## send it a proxy request
101 #echo 400 > EXPECTED
102 #! curl -f -w '%{http_code}\n' -x 127.0.0.1:8080 http://siliconforks.com/ 2> /dev/null > ACTUAL
103 #diff EXPECTED ACTUAL
104
105 # kill $server_pid
106 shutdown
107
108 rm -fr DIR
109 mkdir DIR
110 case `uname` in
111 MINGW*)
112 $VALGRIND jscoverage-server --no-highlight --port=8081 --document-root=recursive --report-dir=DIR --no-instrument=1/ &
113 ;;
114 *)
115 $VALGRIND jscoverage-server --no-highlight --port=8081 --document-root=recursive --report-dir=DIR --no-instrument=/1/ &
116 ;;
117 esac
118 server_pid=$!
119 server_port=8081
120
121 sleep $delay
122
123 wget -q -O- http://127.0.0.1:8081/script.js > OUT
124 cat recursive.expected/script.js ../report.js | sed 's/@PREFIX@/\//g' | diff - OUT
125 wget -q -O- http://127.0.0.1:8081/1/1.js | diff recursive/1/1.js -
126 wget -q -O- http://127.0.0.1:8081/1/2/2.js | diff recursive/1/2/2.js -
127
128 # kill $server_pid
129 shutdown
130
131 $VALGRIND jscoverage-server --no-highlight --port 8082 --document-root recursive --report-dir DIR --no-instrument 1/ &
132 server_pid=$!
133 server_port=8082
134
135 sleep $delay
136
137 wget -q -O- http://127.0.0.1:8082/script.js > OUT
138 cat recursive.expected/script.js ../report.js | sed 's/@PREFIX@/\//g' | diff - OUT
139 wget -q -O- http://127.0.0.1:8082/1/1.js | diff recursive/1/1.js -
140 wget -q -O- http://127.0.0.1:8082/1/2/2.js | diff recursive/1/2/2.js -

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.24