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

Contents of /trunk/tests/store.sh

Parent Directory Parent Directory | Revision Log Revision Log


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

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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.24