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

Annotation of /trunk/tests/store.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 337 - (hide annotations)
Thu Oct 23 20:10:48 2008 UTC (10 years, 11 months ago) by siliconforks
File MIME type: application/x-sh
File size: 4493 byte(s)
Fix tests to work with SpiderMonkey 1.8.

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