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

Annotation of /trunk/tests/proxy.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 114 - (hide annotations)
Sat May 31 21:39:39 2008 UTC (12 years, 1 month ago) by siliconforks
File MIME type: application/x-sh
File size: 5913 byte(s)
Add tests for jscoverage-server.

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