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

Annotation of /trunk/tests/store.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 130 - (hide annotations)
Tue Jun 3 02:41:23 2008 UTC (11 years, 3 months ago) by siliconforks
File MIME type: application/x-sh
File size: 4222 byte(s)
Don't use `function' keyword.

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 130 shutdown() {
22 siliconforks 114 wget -q -O- --post-data= "http://127.0.0.1:${server_port}/jscoverage-shutdown" > /dev/null
23     wait $server_pid
24     }
25    
26 siliconforks 130 cleanup() {
27 siliconforks 114 # rm -fr DIR
28     # kill $server_pid
29     shutdown
30     if [ "$origin_server_pid" != "" ]
31     then
32 siliconforks 126 kill -9 $origin_server_pid
33 siliconforks 114 fi
34     }
35    
36     trap 'cleanup' 0 1 2 3 15
37    
38     export PATH=.:..:../js:$PATH
39    
40     if [ -z "$VALGRIND" ]
41     then
42     delay=0.2
43     else
44     delay=2
45     fi
46    
47     rm -fr DIR
48     $VALGRIND jscoverage-server --document-root=recursive --report-dir=DIR &
49     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     js json-cmp.js TMP DIR/jscoverage.json
58    
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     js json-cmp.js TMP DIR/jscoverage.json
63    
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     shutdown
70    
71     cd recursive
72 siliconforks 126 perl ../server.pl > /dev/null 2> /dev/null &
73 siliconforks 114 origin_server_pid=$!
74     cd ..
75    
76     rm -fr DIR
77     $VALGRIND jscoverage-server --proxy --report-dir=DIR > OUT 2> ERR &
78     server_pid=$!
79     server_port=8080
80    
81     sleep $delay
82    
83     # test with proxy
84     cat store.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:8000\\//g" > TMP
85     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
86     cat store.expected.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:8000\\//g" > TMP
87     js json-cmp.js TMP DIR/jscoverage.json
88    
89     cat store.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:8000\\//g" > TMP
90     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
91     cat store.expected.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:8000\\//g" | sed "s/,1/,2/g" > TMP
92     js json-cmp.js TMP DIR/jscoverage.json
93    
94     # test cached source
95     rm -fr DIR
96     cat store.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:8000\\//g" > TMP
97     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
98     cat store.expected.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:8000\\//g" > TMP
99     js json-cmp.js TMP DIR/jscoverage.json
100    
101     shutdown
102    
103     rm -fr DIR
104     $VALGRIND jscoverage-server --proxy --report-dir=DIR > OUT 2> ERR &
105     server_pid=$!
106     server_port=8080
107    
108     sleep $delay
109    
110     # store JSON with bad source URLs
111     cat store.json | sed "s/@PREFIX@//g" > TMP
112     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
113     js json-cmp.js store-bad-source-urls.expected.json DIR/jscoverage.json
114     sort ERR -o ERR
115 siliconforks 126 diff --strip-trailing-cr store-bad-source-urls.expected.err ERR
116 siliconforks 114
117     shutdown
118    
119     rm -fr DIR
120     $VALGRIND jscoverage-server --proxy --report-dir=DIR > OUT 2> ERR &
121     server_pid=$!
122     server_port=8080
123    
124     sleep $delay
125    
126     # store JSON with unreachable source URLs
127     cat store.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:1\\//g" > TMP
128     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
129     js json-cmp.js store-unreachable-source-urls.expected.json DIR/jscoverage.json
130     sort ERR -o ERR
131 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