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

Annotation of /trunk/tests/server.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 276 - (hide annotations)
Sat Oct 11 22:38:19 2008 UTC (11 years, 1 month ago) by siliconforks
File MIME type: application/x-sh
File size: 6395 byte(s)
Add more tests.
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 249 rm -fr EXPECTED ACTUAL DIR OUT
44 siliconforks 114 mkdir DIR
45 siliconforks 181 $VALGRIND jscoverage-server --no-highlight --document-root=recursive --report-dir=DIR &
46 siliconforks 114 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 siliconforks 218 wget -q -O- http://127.0.0.1:8080/x | diff recursive/x -
57 siliconforks 114 wget -q -O- http://127.0.0.1:8080/1/1.html | diff recursive/1/1.html -
58     wget -q -O- http://127.0.0.1:8080/1/1.css | diff recursive/1/1.css -
59     wget -q -O- http://127.0.0.1:8080/1/2/2.html | diff recursive/1/2/2.html -
60     wget -q -O- http://127.0.0.1:8080/1/2/2.css | diff recursive/1/2/2.css -
61    
62     # test query string
63     wget -q -O- http://127.0.0.1:8080/index.html?foo | diff recursive/index.html -
64    
65     # test javascript
66     wget -q -O- http://127.0.0.1:8080/script.js > OUT
67 siliconforks 193 cat ../report.js recursive.expected/script.js | sed 's/@PREFIX@/\//g' | diff - OUT
68 siliconforks 114 wget -q -O- http://127.0.0.1:8080/1/1.js > OUT
69 siliconforks 193 cat ../report.js recursive.expected/1/1.js | sed 's/@PREFIX@/\//g' | diff - OUT
70 siliconforks 114 wget -q -O- http://127.0.0.1:8080/1/2/2.js > OUT
71 siliconforks 193 cat ../report.js recursive.expected/1/2/2.js | sed 's/@PREFIX@/\//g' | diff - OUT
72 siliconforks 114
73     # test jscoverage
74     wget -q -O- http://127.0.0.1:8080/jscoverage.html | diff ../jscoverage.html -
75     wget -q -O- http://127.0.0.1:8080/jscoverage.css | diff ../jscoverage.css -
76     wget -q -O- http://127.0.0.1:8080/jscoverage-throbber.gif | diff ../jscoverage-throbber.gif -
77     wget -q -O- http://127.0.0.1:8080/jscoverage.js > OUT
78     echo -e 'jscoverage_isServer = true;\r' | cat ../jscoverage.js - | diff - OUT
79    
80     # load/store
81     wget --post-data='{}' -q -O- http://127.0.0.1:8080/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 -e 'jscoverage_isReport = true;\r' | cat ../jscoverage.js - | diff - DIR/jscoverage.js
87    
88     # 404 not found
89     echo 404 > EXPECTED
90     ! curl -f -w '%{http_code}\n' http://127.0.0.1:8080/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:8080/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:8080/../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:8080 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 siliconforks 126 case `uname` in
112     MINGW*)
113 siliconforks 181 $VALGRIND jscoverage-server --no-highlight --port=8081 --document-root=recursive --report-dir=DIR --no-instrument=1/ &
114 siliconforks 126 ;;
115     *)
116 siliconforks 181 $VALGRIND jscoverage-server --no-highlight --port=8081 --document-root=recursive --report-dir=DIR --no-instrument=/1/ &
117 siliconforks 126 ;;
118     esac
119 siliconforks 114 server_pid=$!
120     server_port=8081
121    
122     sleep $delay
123    
124     wget -q -O- http://127.0.0.1:8081/script.js > OUT
125 siliconforks 193 cat ../report.js recursive.expected/script.js | sed 's/@PREFIX@/\//g' | diff - OUT
126 siliconforks 114 wget -q -O- http://127.0.0.1:8081/1/1.js | diff recursive/1/1.js -
127     wget -q -O- http://127.0.0.1:8081/1/2/2.js | diff recursive/1/2/2.js -
128    
129     # kill $server_pid
130     shutdown
131    
132 siliconforks 181 $VALGRIND jscoverage-server --no-highlight --port 8082 --document-root recursive --report-dir DIR --no-instrument 1/ &
133 siliconforks 114 server_pid=$!
134     server_port=8082
135    
136     sleep $delay
137    
138     wget -q -O- http://127.0.0.1:8082/script.js > OUT
139 siliconforks 193 cat ../report.js recursive.expected/script.js | sed 's/@PREFIX@/\//g' | diff - OUT
140 siliconforks 114 wget -q -O- http://127.0.0.1:8082/1/1.js | diff recursive/1/1.js -
141     wget -q -O- http://127.0.0.1:8082/1/2/2.js | diff recursive/1/2/2.js -
142 siliconforks 258
143     # kill $server_pid
144     shutdown
145    
146     $VALGRIND jscoverage-server --port 8080 --encoding iso-8859-1 --document-root javascript &
147     server_pid=$!
148     server_port=8080
149    
150     sleep $delay
151    
152     wget -q -O- http://127.0.0.1:8080/javascript-iso-8859-1.js > OUT
153     cat ../report.js javascript.expected/javascript-iso-8859-1.js | sed 's/javascript-iso-8859-1.js/\/javascript-iso-8859-1.js/g' | diff - OUT
154    
155     # kill $server_pid
156     shutdown
157    
158     $VALGRIND jscoverage-server --no-highlight --port=8080 --encoding=utf-8 --document-root=javascript-utf-8 &
159     server_pid=$!
160     server_port=8080
161    
162     sleep $delay
163    
164     wget -q -O- http://127.0.0.1:8080/javascript-utf-8.js > OUT
165     cat ../report.js javascript-utf-8.expected/javascript-utf-8.js | sed 's/javascript-utf-8.js/\/javascript-utf-8.js/g' | diff - OUT
166 siliconforks 276
167     # kill $server_pid
168     shutdown
169    
170     $VALGRIND jscoverage-server --port 8080 --encoding BOGUS --document-root javascript &
171     server_pid=$!
172     server_port=8080
173    
174     sleep $delay
175    
176     echo 500 > EXPECTED
177     ! curl -f -w '%{http_code}\n' http://127.0.0.1:8080/javascript-iso-8859-1.js 2> /dev/null > ACTUAL
178     diff EXPECTED ACTUAL
179    
180     # kill $server_pid
181     shutdown
182    
183     $VALGRIND jscoverage-server --port 8080 --encoding utf-8 --document-root javascript &
184     server_pid=$!
185     server_port=8080
186    
187     sleep $delay
188    
189     echo 500 > EXPECTED
190     ! curl -f -w '%{http_code}\n' http://127.0.0.1:8080/javascript-iso-8859-1.js 2> /dev/null > ACTUAL
191     diff EXPECTED ACTUAL

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.24