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

Annotation of /trunk/tests/server.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 610 - (hide 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 siliconforks 114 #!/bin/sh
2     # server.sh - test jscoverage-server
3 siliconforks 505 # Copyright (C) 2008, 2009, 2010 siliconforks.com
4 siliconforks 114 #
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 siliconforks 130 shutdown() {
22 siliconforks 114 wget -q -O- --post-data= "http://127.0.0.1:${server_port}/jscoverage-shutdown" > /dev/null
23     wait $server_pid
24     }
25    
26 siliconforks 130 cleanup() {
27 siliconforks 114 rm -fr EXPECTED ACTUAL DIR OUT
28     # kill $server_pid
29     shutdown
30     }
31    
32     trap 'cleanup' 0 1 2 3 15
33    
34 siliconforks 529 . ./common.sh
35 siliconforks 114
36 siliconforks 314 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 siliconforks 249 rm -fr EXPECTED ACTUAL DIR OUT
44 siliconforks 114 mkdir DIR
45 siliconforks 610 server_port=`perl unused-port.pl`
46     $VALGRIND jscoverage-server --port=$server_port --no-highlight --document-root=recursive --report-dir=DIR &
47 siliconforks 114 server_pid=$!
48    
49 siliconforks 610 wait_for_server http://127.0.0.1:${server_port}/jscoverage.html
50 siliconforks 114
51 siliconforks 610 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 siliconforks 114
62     # test query string
63 siliconforks 610 wget -q -O- http://127.0.0.1:${server_port}/index.html?foo | diff recursive/index.html -
64 siliconforks 114
65     # test javascript
66 siliconforks 610 wget -q -O- http://127.0.0.1:${server_port}/script.js > OUT
67 siliconforks 532 cat ../report.js ../header.txt ../header.js recursive.expected/script.js | sed 's/@PREFIX@/\//g' | diff --strip-trailing-cr - OUT
68 siliconforks 610 wget -q -O- http://127.0.0.1:${server_port}/1/1.js > OUT
69 siliconforks 532 cat ../report.js ../header.txt ../header.js recursive.expected/1/1.js | sed 's/@PREFIX@/\//g' | diff --strip-trailing-cr - OUT
70 siliconforks 610 wget -q -O- http://127.0.0.1:${server_port}/1/2/2.js > OUT
71 siliconforks 532 cat ../report.js ../header.txt ../header.js recursive.expected/1/2/2.js | sed 's/@PREFIX@/\//g' | diff --strip-trailing-cr - OUT
72 siliconforks 114
73     # test jscoverage
74 siliconforks 610 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 siliconforks 442 echo 'jscoverage_isServer = true;' | cat ../jscoverage.js - | diff --strip-trailing-cr - OUT
79 siliconforks 114
80     # load/store
81 siliconforks 610 wget --post-data='{}' -q -O- http://127.0.0.1:${server_port}/jscoverage-store > /dev/null
82 siliconforks 114 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 siliconforks 442 echo 'jscoverage_isReport = true;' | cat ../jscoverage.js - | diff --strip-trailing-cr - DIR/jscoverage.js
87 siliconforks 114
88     # 404 not found
89     echo 404 > EXPECTED
90 siliconforks 610 ! curl -f -w '%{http_code}\n' http://127.0.0.1:${server_port}/missing 2> /dev/null > ACTUAL
91 siliconforks 114 diff EXPECTED ACTUAL
92     echo 404 > EXPECTED
93 siliconforks 610 ! curl -f -w '%{http_code}\n' http://127.0.0.1:${server_port}/jscoverage-missing 2> /dev/null > ACTUAL
94 siliconforks 114 diff EXPECTED ACTUAL
95    
96     # 403 forbidden
97     echo 403 > EXPECTED
98 siliconforks 610 ! curl -f -w '%{http_code}\n' http://127.0.0.1:${server_port}/../Makefile.am 2> /dev/null > ACTUAL
99 siliconforks 114 diff EXPECTED ACTUAL
100    
101     ## send it a proxy request
102     #echo 400 > EXPECTED
103 siliconforks 610 #! curl -f -w '%{http_code}\n' -x 127.0.0.1:${server_port} http://siliconforks.com/ 2> /dev/null > ACTUAL
104 siliconforks 114 #diff EXPECTED ACTUAL
105    
106     # kill $server_pid
107     shutdown
108    
109     rm -fr DIR
110     mkdir DIR
111 siliconforks 126 case `uname` in
112     MINGW*)
113 siliconforks 610 $VALGRIND jscoverage-server --no-highlight --port=${server_port} --document-root=recursive --report-dir=DIR --no-instrument=1/ &
114 siliconforks 126 ;;
115     *)
116 siliconforks 610 $VALGRIND jscoverage-server --no-highlight --port=${server_port} --document-root=recursive --report-dir=DIR --no-instrument=/1/ &
117 siliconforks 126 ;;
118     esac
119 siliconforks 114 server_pid=$!
120    
121 siliconforks 610 wait_for_server http://127.0.0.1:${server_port}/jscoverage.html
122 siliconforks 114
123 siliconforks 610 wget -q -O- http://127.0.0.1:${server_port}/script.js > OUT
124 siliconforks 532 cat ../report.js ../header.txt ../header.js recursive.expected/script.js | sed 's/@PREFIX@/\//g' | diff --strip-trailing-cr - OUT
125 siliconforks 610 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 siliconforks 114
128     # kill $server_pid
129     shutdown
130    
131 siliconforks 610 $VALGRIND jscoverage-server --no-highlight --port ${server_port} --document-root recursive --report-dir DIR --no-instrument 1/ &
132 siliconforks 114 server_pid=$!
133    
134 siliconforks 610 wait_for_server http://127.0.0.1:${server_port}/jscoverage.html
135 siliconforks 114
136 siliconforks 610 wget -q -O- http://127.0.0.1:${server_port}/script.js > OUT
137 siliconforks 532 cat ../report.js ../header.txt ../header.js recursive.expected/script.js | sed 's/@PREFIX@/\//g' | diff --strip-trailing-cr - OUT
138 siliconforks 610 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 siliconforks 258
141     # kill $server_pid
142     shutdown
143    
144 siliconforks 610 $VALGRIND jscoverage-server --port ${server_port} --encoding iso-8859-1 --document-root javascript &
145 siliconforks 258 server_pid=$!
146    
147 siliconforks 610 wait_for_server http://127.0.0.1:${server_port}/jscoverage.html
148 siliconforks 258
149 siliconforks 314 case "$character_encoding_support" in
150     yes)
151 siliconforks 529 rm -fr EXPECTED
152 siliconforks 610 wget -q -O- http://127.0.0.1:${server_port}/javascript-iso-8859-1.js > OUT
153 siliconforks 529 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 siliconforks 314 ;;
157     *)
158     echo 500 > EXPECTED
159 siliconforks 610 ! curl -f -w '%{http_code}\n' http://127.0.0.1:${server_port}/javascript-iso-8859-1.js 2> /dev/null > ACTUAL
160 siliconforks 314 diff EXPECTED ACTUAL
161     ;;
162     esac
163 siliconforks 258
164     # kill $server_pid
165     shutdown
166    
167 siliconforks 610 $VALGRIND jscoverage-server --no-highlight --port=${server_port} --encoding=utf-8 --document-root=javascript-utf-8 &
168 siliconforks 258 server_pid=$!
169    
170 siliconforks 610 wait_for_server http://127.0.0.1:${server_port}/jscoverage.html
171 siliconforks 258
172 siliconforks 314 case "$character_encoding_support" in
173     yes)
174 siliconforks 529 rm -fr EXPECTED
175 siliconforks 610 wget -q -O- http://127.0.0.1:${server_port}/javascript-utf-8.js > OUT
176 siliconforks 529 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 siliconforks 314 ;;
180     *)
181     echo 500 > EXPECTED
182 siliconforks 610 ! curl -f -w '%{http_code}\n' http://127.0.0.1:${server_port}/javascript-utf-8.js 2> /dev/null > ACTUAL
183 siliconforks 314 diff EXPECTED ACTUAL
184     ;;
185     esac
186 siliconforks 276
187     # kill $server_pid
188     shutdown
189    
190 siliconforks 610 $VALGRIND jscoverage-server --port ${server_port} --encoding BOGUS --document-root javascript &
191 siliconforks 276 server_pid=$!
192    
193 siliconforks 610 wait_for_server http://127.0.0.1:${server_port}/jscoverage.html
194 siliconforks 276
195     echo 500 > EXPECTED
196 siliconforks 610 ! curl -f -w '%{http_code}\n' http://127.0.0.1:${server_port}/javascript-iso-8859-1.js 2> /dev/null > ACTUAL
197 siliconforks 276 diff EXPECTED ACTUAL
198    
199     # kill $server_pid
200     shutdown
201    
202 siliconforks 610 $VALGRIND jscoverage-server --port ${server_port} --encoding utf-8 --document-root javascript &
203 siliconforks 276 server_pid=$!
204    
205 siliconforks 610 wait_for_server http://127.0.0.1:${server_port}/jscoverage.html
206 siliconforks 276
207     echo 500 > EXPECTED
208 siliconforks 610 ! curl -f -w '%{http_code}\n' http://127.0.0.1:${server_port}/javascript-iso-8859-1.js 2> /dev/null > ACTUAL
209 siliconforks 276 diff EXPECTED ACTUAL

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.24