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

Annotation of /trunk/tests/server.sh

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.24