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

Annotation of /trunk/tests/charset.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 314 - (hide annotations)
Mon Oct 13 17:52:41 2008 UTC (11 years, 9 months ago) by siliconforks
File MIME type: application/x-sh
File size: 3026 byte(s)
Make tests work with no character encoding support.
1 siliconforks 251 #!/bin/sh
2     # charset.sh - test jscoverage-server with different charset values
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     shutdown() {
22     wget -q -O- --post-data= "http://127.0.0.1:${proxy_server_port}/jscoverage-shutdown" > /dev/null
23     wait $proxy_server_pid
24     }
25    
26     cleanup() {
27     shutdown
28     kill -9 $origin_server_pid
29     }
30    
31     trap 'cleanup' 0 1 2 3 15
32    
33     export PATH=.:..:$PATH
34    
35     if [ -z "$VALGRIND" ]
36     then
37     delay=0.2
38     else
39     delay=2
40     fi
41    
42 siliconforks 314 if jscoverage-server --version | grep -q 'iconv\|MultiByteToWideChar'
43     then
44     character_encoding_support=yes
45     else
46     character_encoding_support=no
47     fi
48    
49 siliconforks 251 $VALGRIND jscoverage-server --proxy --no-highlight > OUT 2> ERR &
50     proxy_server_pid=$!
51     proxy_server_port=8080
52    
53     ./http-server-charset &
54     origin_server_pid=$!
55    
56     sleep $delay
57    
58 siliconforks 314 case "$character_encoding_support" in
59     yes)
60     cat ../report.js > EXPECTED
61     cat javascript-utf-8.expected/javascript-utf-8.js | sed 's/javascript-utf-8.js/http:\/\/127.0.0.1:8000\/utf-8.js/g' >> EXPECTED
62     curl -s -x 127.0.0.1:8080 http://127.0.0.1:8000/utf-8.js > ACTUAL
63     diff EXPECTED ACTUAL
64     ;;
65     *)
66     echo 500 > EXPECTED
67     ! curl -f -w '%{http_code}\n' -x 127.0.0.1:8080 http://127.0.0.1:8000/utf-8.js 2> /dev/null > ACTUAL
68     diff EXPECTED ACTUAL
69     ;;
70     esac
71 siliconforks 251
72     shutdown
73    
74     $VALGRIND jscoverage-server --proxy > OUT 2> ERR &
75     proxy_server_pid=$!
76     proxy_server_port=8080
77    
78     sleep $delay
79    
80 siliconforks 314 case "$character_encoding_support" in
81     yes)
82     cat ../report.js > EXPECTED
83     cat javascript.expected/javascript-iso-8859-1.js | sed 's/javascript-iso-8859-1.js/http:\/\/127.0.0.1:8000\/iso-8859-1.js/g' >> EXPECTED
84     curl -s -x 127.0.0.1:8080 http://127.0.0.1:8000/iso-8859-1.js > ACTUAL
85     diff EXPECTED ACTUAL
86     ;;
87     *)
88     echo 500 > EXPECTED
89     ! curl -f -w '%{http_code}\n' -x 127.0.0.1:8080 http://127.0.0.1:8000/iso-8859-1.js 2> /dev/null > ACTUAL
90     diff EXPECTED ACTUAL
91     ;;
92     esac
93 siliconforks 256
94     # bogus charset
95 siliconforks 314 echo 500 > EXPECTED
96 siliconforks 256 ! curl -f -w '%{http_code}\n' -x 127.0.0.1:8080 http://127.0.0.1:8000/bogus.js 2> /dev/null > ACTUAL
97     diff EXPECTED ACTUAL
98    
99     # malformed encoding
100 siliconforks 314 case "$character_encoding_support" in
101     yes)
102     status=502
103     ;;
104     *)
105     status=500
106     ;;
107     esac
108     echo $status > EXPECTED
109 siliconforks 256 ! curl -f -w '%{http_code}\n' -x 127.0.0.1:8080 http://127.0.0.1:8000/malformed.js 2> /dev/null > ACTUAL
110     diff EXPECTED ACTUAL

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.24