PageRenderTime 20ms CodeModel.GetById 12ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/js/lib/Socket.IO-node/support/expresso/deps/jscoverage/tests/charset.sh

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs
Shell | 110 lines | 74 code | 17 blank | 19 comment | 2 complexity | 74b96d2a809d994ac5a0aa193dd6199a MD5 | raw file
  1#!/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
 19set -e
 20
 21shutdown() {
 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
 26cleanup() {
 27  shutdown
 28  kill -9 $origin_server_pid
 29}
 30
 31trap 'cleanup' 0 1 2 3 15
 32
 33export PATH=.:..:$PATH
 34
 35if [ -z "$VALGRIND" ]
 36then
 37  delay=0.2
 38else
 39  delay=2
 40fi
 41
 42if jscoverage-server --version | grep -q 'iconv\|MultiByteToWideChar'
 43then
 44  character_encoding_support=yes
 45else
 46  character_encoding_support=no
 47fi
 48
 49$VALGRIND jscoverage-server --proxy --no-highlight > OUT 2> ERR &
 50proxy_server_pid=$!
 51proxy_server_port=8080
 52
 53./http-server-charset &
 54origin_server_pid=$!
 55
 56sleep $delay
 57
 58case "$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    ;;
 70esac
 71
 72shutdown
 73
 74$VALGRIND jscoverage-server --proxy > OUT 2> ERR &
 75proxy_server_pid=$!
 76proxy_server_port=8080
 77
 78sleep $delay
 79
 80case "$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    ;;
 92esac
 93
 94# bogus charset
 95echo 500 > EXPECTED
 96! curl -f -w '%{http_code}\n' -x 127.0.0.1:8080 http://127.0.0.1:8000/bogus.js 2> /dev/null > ACTUAL
 97diff EXPECTED ACTUAL
 98
 99# malformed encoding
100case "$character_encoding_support" in
101  yes)
102    status=502
103    ;;
104  *)
105    status=500
106    ;;
107esac
108echo $status > EXPECTED
109! curl -f -w '%{http_code}\n' -x 127.0.0.1:8080 http://127.0.0.1:8000/malformed.js 2> /dev/null > ACTUAL
110diff EXPECTED ACTUAL