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

Annotation of /trunk/tests/proxy.sh

Parent Directory Parent Directory | Revision Log Revision Log


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

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     function shutdown() {
22     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 126 function shutdown_perl() {
27     wget -q -O- --post-data= http://127.0.0.1:8000/perl-shutdown > /dev/null
28     wait $origin_server_pid
29     }
30    
31 siliconforks 114 function cleanup() {
32     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     $VALGRIND jscoverage-server --proxy --report-dir=DIR > OUT 2> ERR &
56     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     diff ../jscoverage-sh_main.js DIR/jscoverage-sh_main.js
99     diff ../jscoverage-sh_javascript.js DIR/jscoverage-sh_javascript.js
100     diff ../jscoverage-sh_nedit.css DIR/jscoverage-sh_nedit.css
101     echo -e 'jscoverage_isReport = true;\r' | cat ../jscoverage.js - | diff - DIR/jscoverage.js
102    
103     ## send it an FTP request
104     #echo 400 > EXPECTED
105     #! curl -f -w '%{http_code}\n' -x 127.0.0.1:8080 ftp://ftp.example.com 2> /dev/null > ACTUAL
106     #diff EXPECTED ACTUAL
107     #
108     ## nonexistent domain
109     #echo 500 > EXPECTED
110     #! curl -f -w '%{http_code}\n' -x 127.0.0.1:8080 http://nonexistent 2> /dev/null > ACTUAL
111     #diff EXPECTED ACTUAL
112    
113     # 404 not found
114     echo 404 > EXPECTED
115     ! curl -f -w '%{http_code}\n' -x 127.0.0.1:8080 http://127.0.0.1:8000/missing 2> /dev/null > ACTUAL
116     diff EXPECTED ACTUAL
117     echo 404 > EXPECTED
118     ! curl -f -w '%{http_code}\n' -x 127.0.0.1:8080 http://siliconforks.com/jscoverage-missing 2> /dev/null > ACTUAL
119     diff EXPECTED ACTUAL
120    
121     ## send it a server request
122     #echo 400 > EXPECTED
123     #! curl -f -w '%{http_code}\n' http://127.0.0.1:8080/ 2> /dev/null > ACTUAL
124     #diff EXPECTED ACTUAL
125    
126     # kill $proxy_server_pid
127     shutdown
128    
129     $VALGRIND jscoverage-server --port=8081 --proxy --report-dir=DIR --no-instrument=http://127.0.0.1:8000/1/ &
130     proxy_server_pid=$!
131     proxy_server_port=8081
132    
133     sleep $delay
134    
135     wget -q -O- -e 'http_proxy=http://127.0.0.1:8081/' http://127.0.0.1:8000/script.js > OUT
136     cat recursive.expected/script.js ../report.js | sed 's/@PREFIX@/http:\/\/127.0.0.1:8000\//g' | diff - OUT
137     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 -
138     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