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

Contents of /trunk/tests/store.sh

Parent Directory Parent Directory | Revision Log Revision Log


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

1 #!/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 . 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 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 $VALGRIND jscoverage-server --no-highlight --document-root=recursive --report-dir=DIR &
51 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 json_cmp TMP DIR/jscoverage.json
60
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 json_cmp TMP DIR/jscoverage.json
65
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 # 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 json_cmp TMP DIR/DIR/jscoverage.json
76
77 shutdown
78
79 cd recursive
80 perl ../server.pl > /dev/null 2> /dev/null &
81 origin_server_pid=$!
82 cd ..
83
84 rm -fr DIR
85 $VALGRIND jscoverage-server --no-highlight --proxy --report-dir=DIR > OUT 2> ERR &
86 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 json_cmp TMP DIR/jscoverage.json
96
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 json_cmp TMP DIR/jscoverage.json
101
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 json_cmp TMP DIR/jscoverage.json
108
109 shutdown
110
111 rm -fr DIR
112 $VALGRIND jscoverage-server --no-highlight --proxy --report-dir=DIR > OUT 2> ERR &
113 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 json_cmp store-bad-source-urls.expected.json DIR/jscoverage.json
122 sort ERR -o ERR
123 diff --strip-trailing-cr store-bad-source-urls.expected.err ERR
124
125 shutdown
126
127 rm -fr DIR
128 $VALGRIND jscoverage-server --no-highlight --proxy --report-dir=DIR > OUT 2> ERR &
129 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 json_cmp store-unreachable-source-urls.expected.json DIR/jscoverage.json
138 sort ERR -o ERR
139 diff --strip-trailing-cr store-unreachable-source-urls.expected.err ERR

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.24