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

Annotation of /trunk/tests/store.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 610 - (hide annotations)
Fri Sep 24 20:35:36 2010 UTC (10 years, 1 month ago) by siliconforks
File MIME type: application/x-sh
File size: 5273 byte(s)
Remove hard-coded port numbers.

1 siliconforks 114 #!/bin/sh
2     # store.sh - test storing coverage reports with jscoverage-server
3 siliconforks 505 # Copyright (C) 2008, 2009, 2010 siliconforks.com
4 siliconforks 114 #
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 443 . ./common.sh
22 siliconforks 337
23 siliconforks 130 shutdown() {
24 siliconforks 114 wget -q -O- --post-data= "http://127.0.0.1:${server_port}/jscoverage-shutdown" > /dev/null
25     wait $server_pid
26     }
27    
28 siliconforks 130 cleanup() {
29 siliconforks 114 # rm -fr DIR
30     # kill $server_pid
31     shutdown
32     if [ "$origin_server_pid" != "" ]
33     then
34 siliconforks 126 kill -9 $origin_server_pid
35 siliconforks 114 fi
36     }
37    
38     trap 'cleanup' 0 1 2 3 15
39    
40     rm -fr DIR
41 siliconforks 610 server_port=`perl unused-port.pl`
42     $VALGRIND jscoverage-server --port=$server_port --no-highlight --document-root=recursive --report-dir=DIR &
43 siliconforks 114 server_pid=$!
44    
45 siliconforks 610 wait_for_server http://127.0.0.1:${server_port}/jscoverage.html
46 siliconforks 114
47     cat store.json | sed "s/@PREFIX@/\\//g" > TMP
48 siliconforks 610 wget --post-file=TMP -q -O- http://127.0.0.1:${server_port}/jscoverage-store > /dev/null
49 siliconforks 114 cat store.expected.json | sed "s/@PREFIX@/\\//g" > TMP
50 siliconforks 337 json_cmp TMP DIR/jscoverage.json
51 siliconforks 114
52     cat store.json | sed "s/@PREFIX@/\\//g" > TMP
53 siliconforks 610 wget --post-file=TMP -q -O- http://127.0.0.1:${server_port}/jscoverage-store > /dev/null
54 siliconforks 114 cat store.expected.json | sed "s/@PREFIX@/\\//g" | sed "s/,1/,2/g" > TMP
55 siliconforks 337 json_cmp TMP DIR/jscoverage.json
56 siliconforks 114
57     # try invalid method
58     echo 405 > EXPECTED
59 siliconforks 610 ! curl -f -w '%{http_code}\n' http://127.0.0.1:${server_port}/jscoverage-store 2> /dev/null > ACTUAL
60 siliconforks 114 diff EXPECTED ACTUAL
61    
62 siliconforks 259 # try with a path
63     cat store.json | sed "s/@PREFIX@/\\//g" > TMP
64 siliconforks 610 wget --post-file=TMP -q -O- http://127.0.0.1:${server_port}/jscoverage-store/DIR > /dev/null
65 siliconforks 259 cat store.expected.json | sed "s/@PREFIX@/\\//g" > TMP
66 siliconforks 337 json_cmp TMP DIR/DIR/jscoverage.json
67 siliconforks 259
68 siliconforks 114 shutdown
69    
70     cd recursive
71 siliconforks 610 origin_server_port=`perl ../unused-port.pl`
72     perl ../server.pl $origin_server_port > /dev/null 2> /dev/null &
73 siliconforks 114 origin_server_pid=$!
74     cd ..
75    
76     rm -fr DIR
77 siliconforks 610 server_port=`perl unused-port.pl`
78     $VALGRIND jscoverage-server --port=$server_port --no-highlight --proxy --report-dir=DIR > OUT 2> ERR &
79 siliconforks 114 server_pid=$!
80    
81 siliconforks 610 wait_for_server http://127.0.0.1:${origin_server_port}/index.html
82     wait_for_server http://127.0.0.1:${server_port}/jscoverage.html
83 siliconforks 114
84     # test with proxy
85 siliconforks 610 cat store.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:${origin_server_port}\\//g" > TMP
86     wget --post-file=TMP -q -O- -e "http_proxy=http://127.0.0.1:${server_port}/" http://127.0.0.1:${origin_server_port}/jscoverage-store > /dev/null
87     cat store.expected.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:${origin_server_port}\\//g" > TMP
88 siliconforks 337 json_cmp TMP DIR/jscoverage.json
89 siliconforks 114
90 siliconforks 610 cat store.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:${origin_server_port}\\//g" > TMP
91     wget --post-file=TMP -q -O- -e "http_proxy=http://127.0.0.1:${server_port}/" http://127.0.0.1:${origin_server_port}/jscoverage-store > /dev/null
92     cat store.expected.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:${origin_server_port}\\//g" | sed "s/,1/,2/g" > TMP
93 siliconforks 337 json_cmp TMP DIR/jscoverage.json
94 siliconforks 114
95     # test cached source
96     rm -fr DIR
97 siliconforks 610 cat store.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:${origin_server_port}\\//g" > TMP
98     wget --post-file=TMP -q -O- -e "http_proxy=http://127.0.0.1:${server_port}/" http://127.0.0.1:${origin_server_port}/jscoverage-store > /dev/null
99     cat store.expected.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:${origin_server_port}\\//g" > TMP
100 siliconforks 337 json_cmp TMP DIR/jscoverage.json
101 siliconforks 114
102     shutdown
103    
104     rm -fr DIR
105 siliconforks 610 server_port=`perl unused-port.pl`
106     $VALGRIND jscoverage-server --port=$server_port --no-highlight --proxy --report-dir=DIR > OUT 2> ERR &
107 siliconforks 114 server_pid=$!
108    
109 siliconforks 610 wait_for_server http://127.0.0.1:${server_port}/jscoverage.html
110 siliconforks 114
111     # store JSON with bad source URLs
112     cat store.json | sed "s/@PREFIX@//g" > TMP
113 siliconforks 610 wget --post-file=TMP -q -O- -e "http_proxy=http://127.0.0.1:${server_port}/" http://127.0.0.1:${origin_server_port}/jscoverage-store > /dev/null
114 siliconforks 337 json_cmp store-bad-source-urls.expected.json DIR/jscoverage.json
115 siliconforks 114 sort ERR -o ERR
116 siliconforks 126 diff --strip-trailing-cr store-bad-source-urls.expected.err ERR
117 siliconforks 114
118     shutdown
119    
120     rm -fr DIR
121 siliconforks 610 server_port=`perl unused-port.pl`
122     $VALGRIND jscoverage-server --port=$server_port --no-highlight --proxy --report-dir=DIR > OUT 2> ERR &
123 siliconforks 114 server_pid=$!
124    
125 siliconforks 610 wait_for_server http://127.0.0.1:${server_port}/jscoverage.html
126 siliconforks 114
127 siliconforks 574 unused_port=`perl unused-port.pl`
128     cat store.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:$unused_port\\//g" > TMP
129 siliconforks 610 wget --post-file=TMP -q -O- -e "http_proxy=http://127.0.0.1:${server_port}/" http://127.0.0.1:${origin_server_port}/jscoverage-store > /dev/null
130 siliconforks 574 cat store-unreachable-source-urls.expected.json | sed "s/@PORT@/$unused_port/g" > TMP
131     json_cmp TMP DIR/jscoverage.json
132     cat store-unreachable-source-urls.expected.err | sed "s/@PORT@/$unused_port/g" > TMP
133 siliconforks 114 sort ERR -o ERR
134 siliconforks 574 diff --strip-trailing-cr TMP ERR

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.24