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

Annotation of /trunk/tests/proxy.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 181 - (hide annotations)
Sun Sep 21 18:42:02 2008 UTC (11 years, 2 months ago) by siliconforks
File MIME type: application/x-sh
File size: 5820 byte(s)
Fix tests.

1 siliconforks 114 #!/bin/sh
2     # proxy.sh - test jscoverage-server --proxy
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:${proxy_server_port}/jscoverage-shutdown" > /dev/null
23     wait $proxy_server_pid
24     }
25    
26 siliconforks 130 shutdown_perl() {
27 siliconforks 126 wget -q -O- --post-data= http://127.0.0.1:8000/perl-shutdown > /dev/null
28     wait $origin_server_pid
29     }
30    
31 siliconforks 130 cleanup() {
32 siliconforks 114 rm -fr EXPECTED ACTUAL DIR OUT
33     shutdown
34 siliconforks 126 shutdown_perl
35 siliconforks 114 }
36    
37     trap 'cleanup' 0 1 2 3 15
38    
39     export PATH=.:..:$PATH
40    
41     if [ -z "$VALGRIND" ]
42     then
43     delay=0.2
44     else
45     delay=2
46     fi
47    
48     cd recursive
49 siliconforks 126 perl ../server.pl > /dev/null 2> /dev/null &
50     origin_server_pid=$!
51 siliconforks 114 cd ..
52    
53     rm -fr DIR
54     mkdir DIR
55 siliconforks 181 $VALGRIND jscoverage-server --no-highlight --proxy --report-dir=DIR > OUT 2> ERR &
56 siliconforks 114 proxy_server_pid=$!
57     proxy_server_port=8080
58    
59     sleep $delay
60    
61     wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/index.html | diff recursive/index.html -
62     wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/style.css | diff recursive/style.css -
63     wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/unix.txt | diff recursive/unix.txt -
64     wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/windows.txt | diff recursive/windows.txt -
65     wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/image.png | diff recursive/image.png -
66     wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/1/1.html | diff recursive/1/1.html -
67     wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/1/1.css | diff recursive/1/1.css -
68     wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/1/2/2.html | diff recursive/1/2/2.html -
69     wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/1/2/2.css | diff recursive/1/2/2.css -
70    
71     # test query string
72     wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/index.html?foo | diff recursive/index.html -
73    
74     # test POST
75     wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' --post-file=recursive/index.html http://127.0.0.1:8000/ | diff recursive/index.html -
76    
77     # test javascript
78     wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/script.js > OUT
79     cat recursive.expected/script.js ../report.js | sed 's/@PREFIX@/http:\/\/127.0.0.1:8000\//g' | diff - OUT
80     wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/1/1.js > OUT
81     cat recursive.expected/1/1.js ../report.js | sed 's/@PREFIX@/http:\/\/127.0.0.1:8000\//g' | diff - OUT
82     wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/1/2/2.js > OUT
83     cat recursive.expected/1/2/2.js ../report.js | sed 's/@PREFIX@/http:\/\/127.0.0.1:8000\//g' | diff - OUT
84    
85     ## test jscoverage
86     wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://siliconforks.com/jscoverage.html | diff ../jscoverage.html -
87     wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://siliconforks.com/jscoverage.css | diff ../jscoverage.css -
88     wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://siliconforks.com/jscoverage-throbber.gif | diff ../jscoverage-throbber.gif -
89     wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://siliconforks.com/jscoverage.js > OUT
90     echo -e 'jscoverage_isServer = true;\r' | cat ../jscoverage.js - | diff - OUT
91    
92     # load/store
93     wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' --post-data='{}' http://siliconforks.com/jscoverage-store > /dev/null
94     echo -n '{}' | diff - DIR/jscoverage.json
95     diff ../jscoverage.html DIR/jscoverage.html
96     diff ../jscoverage.css DIR/jscoverage.css
97     diff ../jscoverage-throbber.gif DIR/jscoverage-throbber.gif
98     echo -e 'jscoverage_isReport = true;\r' | cat ../jscoverage.js - | diff - DIR/jscoverage.js
99    
100     ## send it an FTP request
101     #echo 400 > EXPECTED
102     #! curl -f -w '%{http_code}\n' -x 127.0.0.1:8080 ftp://ftp.example.com 2> /dev/null > ACTUAL
103     #diff EXPECTED ACTUAL
104     #
105     ## nonexistent domain
106     #echo 500 > EXPECTED
107     #! curl -f -w '%{http_code}\n' -x 127.0.0.1:8080 http://nonexistent 2> /dev/null > ACTUAL
108     #diff EXPECTED ACTUAL
109    
110     # 404 not found
111     echo 404 > EXPECTED
112     ! curl -f -w '%{http_code}\n' -x 127.0.0.1:8080 http://127.0.0.1:8000/missing 2> /dev/null > ACTUAL
113     diff EXPECTED ACTUAL
114     echo 404 > EXPECTED
115     ! curl -f -w '%{http_code}\n' -x 127.0.0.1:8080 http://siliconforks.com/jscoverage-missing 2> /dev/null > ACTUAL
116     diff EXPECTED ACTUAL
117    
118     ## send it a server request
119     #echo 400 > EXPECTED
120     #! curl -f -w '%{http_code}\n' http://127.0.0.1:8080/ 2> /dev/null > ACTUAL
121     #diff EXPECTED ACTUAL
122    
123     # kill $proxy_server_pid
124     shutdown
125    
126 siliconforks 181 $VALGRIND jscoverage-server --no-highlight --port=8081 --proxy --report-dir=DIR --no-instrument=http://127.0.0.1:8000/1/ &
127 siliconforks 114 proxy_server_pid=$!
128     proxy_server_port=8081
129    
130     sleep $delay
131    
132     wget -q -O- -e 'http_proxy=http://127.0.0.1:8081/' http://127.0.0.1:8000/script.js > OUT
133     cat recursive.expected/script.js ../report.js | sed 's/@PREFIX@/http:\/\/127.0.0.1:8000\//g' | diff - OUT
134     wget -q -O- -e 'http_proxy=http://127.0.0.1:8081/' http://127.0.0.1:8000/1/1.js | diff recursive/1/1.js -
135     wget -q -O- -e 'http_proxy=http://127.0.0.1:8081/' http://127.0.0.1:8000/1/2/2.js | diff recursive/1/2/2.js -

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.24