1 |
#!/bin/sh |
#!/bin/sh |
2 |
# store.sh - test storing coverage reports with jscoverage-server |
# store.sh - test storing coverage reports with jscoverage-server |
3 |
# Copyright (C) 2008 siliconforks.com |
# Copyright (C) 2008, 2009 siliconforks.com |
4 |
# |
# |
5 |
# This program is free software; you can redistribute it and/or modify |
# 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 |
# it under the terms of the GNU General Public License as published by |
18 |
|
|
19 |
set -e |
set -e |
20 |
|
|
21 |
|
. ./common.sh |
22 |
|
|
23 |
shutdown() { |
shutdown() { |
24 |
wget -q -O- --post-data= "http://127.0.0.1:${server_port}/jscoverage-shutdown" > /dev/null |
wget -q -O- --post-data= "http://127.0.0.1:${server_port}/jscoverage-shutdown" > /dev/null |
25 |
wait $server_pid |
wait $server_pid |
37 |
|
|
38 |
trap 'cleanup' 0 1 2 3 15 |
trap 'cleanup' 0 1 2 3 15 |
39 |
|
|
|
export PATH=.:..:../js:$PATH |
|
|
|
|
40 |
if [ -z "$VALGRIND" ] |
if [ -z "$VALGRIND" ] |
41 |
then |
then |
42 |
delay=0.2 |
delay=0.2 |
54 |
cat store.json | sed "s/@PREFIX@/\\//g" > TMP |
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 |
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 |
cat store.expected.json | sed "s/@PREFIX@/\\//g" > TMP |
57 |
js json-cmp.js TMP DIR/jscoverage.json |
json_cmp TMP DIR/jscoverage.json |
58 |
|
|
59 |
cat store.json | sed "s/@PREFIX@/\\//g" > TMP |
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 |
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 |
cat store.expected.json | sed "s/@PREFIX@/\\//g" | sed "s/,1/,2/g" > TMP |
62 |
js json-cmp.js TMP DIR/jscoverage.json |
json_cmp TMP DIR/jscoverage.json |
63 |
|
|
64 |
# try invalid method |
# try invalid method |
65 |
echo 405 > EXPECTED |
echo 405 > EXPECTED |
70 |
cat store.json | sed "s/@PREFIX@/\\//g" > TMP |
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 |
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 |
cat store.expected.json | sed "s/@PREFIX@/\\//g" > TMP |
73 |
js json-cmp.js TMP DIR/DIR/jscoverage.json |
json_cmp TMP DIR/DIR/jscoverage.json |
74 |
|
|
75 |
shutdown |
shutdown |
76 |
|
|
90 |
cat store.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:8000\\//g" > TMP |
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 |
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 |
cat store.expected.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:8000\\//g" > TMP |
93 |
js json-cmp.js TMP DIR/jscoverage.json |
json_cmp TMP DIR/jscoverage.json |
94 |
|
|
95 |
cat store.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:8000\\//g" > TMP |
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 |
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 |
cat store.expected.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:8000\\//g" | sed "s/,1/,2/g" > TMP |
98 |
js json-cmp.js TMP DIR/jscoverage.json |
json_cmp TMP DIR/jscoverage.json |
99 |
|
|
100 |
# test cached source |
# test cached source |
101 |
rm -fr DIR |
rm -fr DIR |
102 |
cat store.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:8000\\//g" > TMP |
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 |
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 |
cat store.expected.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:8000\\//g" > TMP |
105 |
js json-cmp.js TMP DIR/jscoverage.json |
json_cmp TMP DIR/jscoverage.json |
106 |
|
|
107 |
shutdown |
shutdown |
108 |
|
|
116 |
# store JSON with bad source URLs |
# store JSON with bad source URLs |
117 |
cat store.json | sed "s/@PREFIX@//g" > TMP |
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 |
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 |
js json-cmp.js store-bad-source-urls.expected.json DIR/jscoverage.json |
json_cmp store-bad-source-urls.expected.json DIR/jscoverage.json |
120 |
sort ERR -o ERR |
sort ERR -o ERR |
121 |
diff --strip-trailing-cr store-bad-source-urls.expected.err ERR |
diff --strip-trailing-cr store-bad-source-urls.expected.err ERR |
122 |
|
|
132 |
# store JSON with unreachable source URLs |
# store JSON with unreachable source URLs |
133 |
cat store.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:1\\//g" > TMP |
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 |
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 |
js json-cmp.js store-unreachable-source-urls.expected.json DIR/jscoverage.json |
json_cmp store-unreachable-source-urls.expected.json DIR/jscoverage.json |
136 |
sort ERR -o ERR |
sort ERR -o ERR |
137 |
diff --strip-trailing-cr store-unreachable-source-urls.expected.err ERR |
diff --strip-trailing-cr store-unreachable-source-urls.expected.err ERR |