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

Contents of /trunk/tests/server.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 126 - (show annotations)
Mon Jun 2 17:53:43 2008 UTC (11 years, 5 months ago) by siliconforks
File MIME type: application/x-sh
File size: 5125 byte(s)
Fixes for MinGW.

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 function 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 function 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 --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 diff ../jscoverage-sh_main.js DIR/jscoverage-sh_main.js
86 diff ../jscoverage-sh_javascript.js DIR/jscoverage-sh_javascript.js
87 diff ../jscoverage-sh_nedit.css DIR/jscoverage-sh_nedit.css
88 echo -e 'jscoverage_isReport = true;\r' | cat ../jscoverage.js - | diff - DIR/jscoverage.js
89
90 # 404 not found
91 echo 404 > EXPECTED
92 ! curl -f -w '%{http_code}\n' http://127.0.0.1:8080/missing 2> /dev/null > ACTUAL
93 diff EXPECTED ACTUAL
94 echo 404 > EXPECTED
95 ! curl -f -w '%{http_code}\n' http://127.0.0.1:8080/jscoverage-missing 2> /dev/null > ACTUAL
96 diff EXPECTED ACTUAL
97
98 # 403 forbidden
99 echo 403 > EXPECTED
100 ! curl -f -w '%{http_code}\n' http://127.0.0.1:8080/../Makefile.am 2> /dev/null > ACTUAL
101 diff EXPECTED ACTUAL
102
103 ## send it a proxy request
104 #echo 400 > EXPECTED
105 #! curl -f -w '%{http_code}\n' -x 127.0.0.1:8080 http://siliconforks.com/ 2> /dev/null > ACTUAL
106 #diff EXPECTED ACTUAL
107
108 # kill $server_pid
109 shutdown
110
111 rm -fr DIR
112 mkdir DIR
113 case `uname` in
114 MINGW*)
115 $VALGRIND jscoverage-server --port=8081 --document-root=recursive --report-dir=DIR --no-instrument=1/ &
116 ;;
117 *)
118 $VALGRIND jscoverage-server --port=8081 --document-root=recursive --report-dir=DIR --no-instrument=/1/ &
119 ;;
120 esac
121 server_pid=$!
122 server_port=8081
123
124 sleep $delay
125
126 wget -q -O- http://127.0.0.1:8081/script.js > OUT
127 cat recursive.expected/script.js ../report.js | sed 's/@PREFIX@/\//g' | diff - OUT
128 wget -q -O- http://127.0.0.1:8081/1/1.js | diff recursive/1/1.js -
129 wget -q -O- http://127.0.0.1:8081/1/2/2.js | diff recursive/1/2/2.js -
130
131 # kill $server_pid
132 shutdown
133
134 $VALGRIND jscoverage-server --port 8082 --document-root recursive --report-dir DIR --no-instrument 1/ &
135 server_pid=$!
136 server_port=8082
137
138 sleep $delay
139
140 wget -q -O- http://127.0.0.1:8082/script.js > OUT
141 cat recursive.expected/script.js ../report.js | sed 's/@PREFIX@/\//g' | diff - OUT
142 wget -q -O- http://127.0.0.1:8082/1/1.js | diff recursive/1/1.js -
143 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