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

Annotation of /trunk/tests/store.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 427 - (hide annotations)
Wed Feb 18 16:08:33 2009 UTC (11 years, 8 months ago) by siliconforks
File MIME type: application/x-sh
File size: 4469 byte(s)
Update Copyright year.
1 siliconforks 114 #!/bin/sh
2     # store.sh - test storing coverage reports with jscoverage-server
3 siliconforks 427 # Copyright (C) 2008, 2009 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 337 . common.sh
22    
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     if [ -z "$VALGRIND" ]
41     then
42     delay=0.2
43     else
44     delay=2
45     fi
46    
47     rm -fr DIR
48 siliconforks 181 $VALGRIND jscoverage-server --no-highlight --document-root=recursive --report-dir=DIR &
49 siliconforks 114 server_pid=$!
50     server_port=8080
51    
52     sleep $delay
53    
54     cat store.json | sed "s/@PREFIX@/\\//g" > TMP
55     wget --post-file=TMP -q -O- http://127.0.0.1:8080/jscoverage-store > /dev/null
56     cat store.expected.json | sed "s/@PREFIX@/\\//g" > TMP
57 siliconforks 337 json_cmp TMP DIR/jscoverage.json
58 siliconforks 114
59     cat store.json | sed "s/@PREFIX@/\\//g" > TMP
60     wget --post-file=TMP -q -O- http://127.0.0.1:8080/jscoverage-store > /dev/null
61     cat store.expected.json | sed "s/@PREFIX@/\\//g" | sed "s/,1/,2/g" > TMP
62 siliconforks 337 json_cmp TMP DIR/jscoverage.json
63 siliconforks 114
64     # try invalid method
65     echo 405 > EXPECTED
66     ! curl -f -w '%{http_code}\n' http://127.0.0.1:8080/jscoverage-store 2> /dev/null > ACTUAL
67     diff EXPECTED ACTUAL
68    
69 siliconforks 259 # try with a path
70     cat store.json | sed "s/@PREFIX@/\\//g" > TMP
71     wget --post-file=TMP -q -O- http://127.0.0.1:8080/jscoverage-store/DIR > /dev/null
72     cat store.expected.json | sed "s/@PREFIX@/\\//g" > TMP
73 siliconforks 337 json_cmp TMP DIR/DIR/jscoverage.json
74 siliconforks 259
75 siliconforks 114 shutdown
76    
77     cd recursive
78 siliconforks 126 perl ../server.pl > /dev/null 2> /dev/null &
79 siliconforks 114 origin_server_pid=$!
80     cd ..
81    
82     rm -fr DIR
83 siliconforks 181 $VALGRIND jscoverage-server --no-highlight --proxy --report-dir=DIR > OUT 2> ERR &
84 siliconforks 114 server_pid=$!
85     server_port=8080
86    
87     sleep $delay
88    
89     # test with proxy
90     cat store.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:8000\\//g" > TMP
91     wget --post-file=TMP -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/jscoverage-store > /dev/null
92     cat store.expected.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:8000\\//g" > TMP
93 siliconforks 337 json_cmp TMP DIR/jscoverage.json
94 siliconforks 114
95     cat store.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:8000\\//g" > TMP
96     wget --post-file=TMP -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/jscoverage-store > /dev/null
97     cat store.expected.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:8000\\//g" | sed "s/,1/,2/g" > TMP
98 siliconforks 337 json_cmp TMP DIR/jscoverage.json
99 siliconforks 114
100     # test cached source
101     rm -fr DIR
102     cat store.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:8000\\//g" > TMP
103     wget --post-file=TMP -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/jscoverage-store > /dev/null
104     cat store.expected.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:8000\\//g" > TMP
105 siliconforks 337 json_cmp TMP DIR/jscoverage.json
106 siliconforks 114
107     shutdown
108    
109     rm -fr DIR
110 siliconforks 181 $VALGRIND jscoverage-server --no-highlight --proxy --report-dir=DIR > OUT 2> ERR &
111 siliconforks 114 server_pid=$!
112     server_port=8080
113    
114     sleep $delay
115    
116     # store JSON with bad source URLs
117     cat store.json | sed "s/@PREFIX@//g" > TMP
118     wget --post-file=TMP -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/jscoverage-store > /dev/null
119 siliconforks 337 json_cmp store-bad-source-urls.expected.json DIR/jscoverage.json
120 siliconforks 114 sort ERR -o ERR
121 siliconforks 126 diff --strip-trailing-cr store-bad-source-urls.expected.err ERR
122 siliconforks 114
123     shutdown
124    
125     rm -fr DIR
126 siliconforks 181 $VALGRIND jscoverage-server --no-highlight --proxy --report-dir=DIR > OUT 2> ERR &
127 siliconforks 114 server_pid=$!
128     server_port=8080
129    
130     sleep $delay
131    
132     # store JSON with unreachable source URLs
133     cat store.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:1\\//g" > TMP
134     wget --post-file=TMP -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/jscoverage-store > /dev/null
135 siliconforks 337 json_cmp store-unreachable-source-urls.expected.json DIR/jscoverage.json
136 siliconforks 114 sort ERR -o ERR
137 siliconforks 126 diff --strip-trailing-cr store-unreachable-source-urls.expected.err ERR

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.24