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

Contents of /trunk/tests/server.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 610 - (show annotations)
Fri Sep 24 20:35:36 2010 UTC (9 years, 1 month ago) by siliconforks
File MIME type: application/x-sh
File size: 8185 byte(s)
Remove hard-coded port numbers.

1 #!/bin/sh
2 # server.sh - test jscoverage-server
3 # Copyright (C) 2008, 2009, 2010 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 . ./common.sh
35
36 if jscoverage-server --version | grep -q 'iconv\|MultiByteToWideChar'
37 then
38 character_encoding_support=yes
39 else
40 character_encoding_support=no
41 fi
42
43 rm -fr EXPECTED ACTUAL DIR OUT
44 mkdir DIR
45 server_port=`perl unused-port.pl`
46 $VALGRIND jscoverage-server --port=$server_port --no-highlight --document-root=recursive --report-dir=DIR &
47 server_pid=$!
48
49 wait_for_server http://127.0.0.1:${server_port}/jscoverage.html
50
51 wget -q -O- http://127.0.0.1:${server_port}/index.html | diff recursive/index.html -
52 wget -q -O- http://127.0.0.1:${server_port}/style.css | diff recursive/style.css -
53 wget -q -O- http://127.0.0.1:${server_port}/unix.txt | diff recursive/unix.txt -
54 wget -q -O- http://127.0.0.1:${server_port}/windows.txt | diff recursive/windows.txt -
55 wget -q -O- http://127.0.0.1:${server_port}/image.png | diff recursive/image.png -
56 wget -q -O- http://127.0.0.1:${server_port}/x | diff recursive/x -
57 wget -q -O- http://127.0.0.1:${server_port}/1/1.html | diff recursive/1/1.html -
58 wget -q -O- http://127.0.0.1:${server_port}/1/1.css | diff recursive/1/1.css -
59 wget -q -O- http://127.0.0.1:${server_port}/1/2/2.html | diff recursive/1/2/2.html -
60 wget -q -O- http://127.0.0.1:${server_port}/1/2/2.css | diff recursive/1/2/2.css -
61
62 # test query string
63 wget -q -O- http://127.0.0.1:${server_port}/index.html?foo | diff recursive/index.html -
64
65 # test javascript
66 wget -q -O- http://127.0.0.1:${server_port}/script.js > OUT
67 cat ../report.js ../header.txt ../header.js recursive.expected/script.js | sed 's/@PREFIX@/\//g' | diff --strip-trailing-cr - OUT
68 wget -q -O- http://127.0.0.1:${server_port}/1/1.js > OUT
69 cat ../report.js ../header.txt ../header.js recursive.expected/1/1.js | sed 's/@PREFIX@/\//g' | diff --strip-trailing-cr - OUT
70 wget -q -O- http://127.0.0.1:${server_port}/1/2/2.js > OUT
71 cat ../report.js ../header.txt ../header.js recursive.expected/1/2/2.js | sed 's/@PREFIX@/\//g' | diff --strip-trailing-cr - OUT
72
73 # test jscoverage
74 wget -q -O- http://127.0.0.1:${server_port}/jscoverage.html | diff ../jscoverage.html -
75 wget -q -O- http://127.0.0.1:${server_port}/jscoverage.css | diff ../jscoverage.css -
76 wget -q -O- http://127.0.0.1:${server_port}/jscoverage-throbber.gif | diff ../jscoverage-throbber.gif -
77 wget -q -O- http://127.0.0.1:${server_port}/jscoverage.js > OUT
78 echo 'jscoverage_isServer = true;' | cat ../jscoverage.js - | diff --strip-trailing-cr - OUT
79
80 # load/store
81 wget --post-data='{}' -q -O- http://127.0.0.1:${server_port}/jscoverage-store > /dev/null
82 echo -n '{}' | diff - DIR/jscoverage.json
83 diff ../jscoverage.html DIR/jscoverage.html
84 diff ../jscoverage.css DIR/jscoverage.css
85 diff ../jscoverage-throbber.gif DIR/jscoverage-throbber.gif
86 echo 'jscoverage_isReport = true;' | cat ../jscoverage.js - | diff --strip-trailing-cr - DIR/jscoverage.js
87
88 # 404 not found
89 echo 404 > EXPECTED
90 ! curl -f -w '%{http_code}\n' http://127.0.0.1:${server_port}/missing 2> /dev/null > ACTUAL
91 diff EXPECTED ACTUAL
92 echo 404 > EXPECTED
93 ! curl -f -w '%{http_code}\n' http://127.0.0.1:${server_port}/jscoverage-missing 2> /dev/null > ACTUAL
94 diff EXPECTED ACTUAL
95
96 # 403 forbidden
97 echo 403 > EXPECTED
98 ! curl -f -w '%{http_code}\n' http://127.0.0.1:${server_port}/../Makefile.am 2> /dev/null > ACTUAL
99 diff EXPECTED ACTUAL
100
101 ## send it a proxy request
102 #echo 400 > EXPECTED
103 #! curl -f -w '%{http_code}\n' -x 127.0.0.1:${server_port} http://siliconforks.com/ 2> /dev/null > ACTUAL
104 #diff EXPECTED ACTUAL
105
106 # kill $server_pid
107 shutdown
108
109 rm -fr DIR
110 mkdir DIR
111 case `uname` in
112 MINGW*)
113 $VALGRIND jscoverage-server --no-highlight --port=${server_port} --document-root=recursive --report-dir=DIR --no-instrument=1/ &
114 ;;
115 *)
116 $VALGRIND jscoverage-server --no-highlight --port=${server_port} --document-root=recursive --report-dir=DIR --no-instrument=/1/ &
117 ;;
118 esac
119 server_pid=$!
120
121 wait_for_server http://127.0.0.1:${server_port}/jscoverage.html
122
123 wget -q -O- http://127.0.0.1:${server_port}/script.js > OUT
124 cat ../report.js ../header.txt ../header.js recursive.expected/script.js | sed 's/@PREFIX@/\//g' | diff --strip-trailing-cr - OUT
125 wget -q -O- http://127.0.0.1:${server_port}/1/1.js | diff --strip-trailing-cr recursive/1/1.js -
126 wget -q -O- http://127.0.0.1:${server_port}/1/2/2.js | diff --strip-trailing-cr recursive/1/2/2.js -
127
128 # kill $server_pid
129 shutdown
130
131 $VALGRIND jscoverage-server --no-highlight --port ${server_port} --document-root recursive --report-dir DIR --no-instrument 1/ &
132 server_pid=$!
133
134 wait_for_server http://127.0.0.1:${server_port}/jscoverage.html
135
136 wget -q -O- http://127.0.0.1:${server_port}/script.js > OUT
137 cat ../report.js ../header.txt ../header.js recursive.expected/script.js | sed 's/@PREFIX@/\//g' | diff --strip-trailing-cr - OUT
138 wget -q -O- http://127.0.0.1:${server_port}/1/1.js | diff --strip-trailing-cr recursive/1/1.js -
139 wget -q -O- http://127.0.0.1:${server_port}/1/2/2.js | diff --strip-trailing-cr recursive/1/2/2.js -
140
141 # kill $server_pid
142 shutdown
143
144 $VALGRIND jscoverage-server --port ${server_port} --encoding iso-8859-1 --document-root javascript &
145 server_pid=$!
146
147 wait_for_server http://127.0.0.1:${server_port}/jscoverage.html
148
149 case "$character_encoding_support" in
150 yes)
151 rm -fr EXPECTED
152 wget -q -O- http://127.0.0.1:${server_port}/javascript-iso-8859-1.js > OUT
153 add_header_to_files javascript.expected
154 cat ../report.js EXPECTED/javascript-iso-8859-1.js | sed 's/javascript-iso-8859-1.js/\/javascript-iso-8859-1.js/g' | diff --strip-trailing-cr - OUT
155 rm -fr EXPECTED
156 ;;
157 *)
158 echo 500 > EXPECTED
159 ! curl -f -w '%{http_code}\n' http://127.0.0.1:${server_port}/javascript-iso-8859-1.js 2> /dev/null > ACTUAL
160 diff EXPECTED ACTUAL
161 ;;
162 esac
163
164 # kill $server_pid
165 shutdown
166
167 $VALGRIND jscoverage-server --no-highlight --port=${server_port} --encoding=utf-8 --document-root=javascript-utf-8 &
168 server_pid=$!
169
170 wait_for_server http://127.0.0.1:${server_port}/jscoverage.html
171
172 case "$character_encoding_support" in
173 yes)
174 rm -fr EXPECTED
175 wget -q -O- http://127.0.0.1:${server_port}/javascript-utf-8.js > OUT
176 add_header_to_files javascript-utf-8.expected
177 cat ../report.js EXPECTED/javascript-utf-8.js | sed 's/javascript-utf-8.js/\/javascript-utf-8.js/g' | diff --strip-trailing-cr - OUT
178 rm -fr EXPECTED
179 ;;
180 *)
181 echo 500 > EXPECTED
182 ! curl -f -w '%{http_code}\n' http://127.0.0.1:${server_port}/javascript-utf-8.js 2> /dev/null > ACTUAL
183 diff EXPECTED ACTUAL
184 ;;
185 esac
186
187 # kill $server_pid
188 shutdown
189
190 $VALGRIND jscoverage-server --port ${server_port} --encoding BOGUS --document-root javascript &
191 server_pid=$!
192
193 wait_for_server http://127.0.0.1:${server_port}/jscoverage.html
194
195 echo 500 > EXPECTED
196 ! curl -f -w '%{http_code}\n' http://127.0.0.1:${server_port}/javascript-iso-8859-1.js 2> /dev/null > ACTUAL
197 diff EXPECTED ACTUAL
198
199 # kill $server_pid
200 shutdown
201
202 $VALGRIND jscoverage-server --port ${server_port} --encoding utf-8 --document-root javascript &
203 server_pid=$!
204
205 wait_for_server http://127.0.0.1:${server_port}/jscoverage.html
206
207 echo 500 > EXPECTED
208 ! curl -f -w '%{http_code}\n' http://127.0.0.1:${server_port}/javascript-iso-8859-1.js 2> /dev/null > ACTUAL
209 diff EXPECTED ACTUAL

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.24