PageRenderTime 18ms CodeModel.GetById 8ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs
Shell | 216 lines | 141 code | 41 blank | 34 comment | 2 complexity | b48ef6d78bb8fd959ee6b8e5cc388d58 MD5 | raw file
  1#!/bin/sh
  2#    server.sh - test 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
 19set -e
 20
 21shutdown() {
 22  wget -q -O- --post-data= "http://127.0.0.1:${server_port}/jscoverage-shutdown" > /dev/null
 23  wait $server_pid
 24}
 25
 26cleanup() {
 27  rm -fr EXPECTED ACTUAL DIR OUT
 28  # kill $server_pid
 29  shutdown
 30}
 31
 32trap 'cleanup' 0 1 2 3 15
 33
 34export PATH=.:..:$PATH
 35
 36if [ -z "$VALGRIND" ]
 37then
 38  delay=0.2
 39else
 40  delay=2
 41fi
 42
 43if jscoverage-server --version | grep -q 'iconv\|MultiByteToWideChar'
 44then
 45  character_encoding_support=yes
 46else
 47  character_encoding_support=no
 48fi
 49
 50rm -fr EXPECTED ACTUAL DIR OUT
 51mkdir DIR
 52$VALGRIND jscoverage-server --no-highlight --document-root=recursive --report-dir=DIR &
 53server_pid=$!
 54server_port=8080
 55
 56sleep $delay
 57
 58wget -q -O- http://127.0.0.1:8080/index.html | diff recursive/index.html -
 59wget -q -O- http://127.0.0.1:8080/style.css | diff recursive/style.css -
 60wget -q -O- http://127.0.0.1:8080/unix.txt | diff recursive/unix.txt -
 61wget -q -O- http://127.0.0.1:8080/windows.txt | diff recursive/windows.txt -
 62wget -q -O- http://127.0.0.1:8080/image.png | diff recursive/image.png -
 63wget -q -O- http://127.0.0.1:8080/x | diff recursive/x -
 64wget -q -O- http://127.0.0.1:8080/1/1.html | diff recursive/1/1.html -
 65wget -q -O- http://127.0.0.1:8080/1/1.css | diff recursive/1/1.css -
 66wget -q -O- http://127.0.0.1:8080/1/2/2.html | diff recursive/1/2/2.html -
 67wget -q -O- http://127.0.0.1:8080/1/2/2.css | diff recursive/1/2/2.css -
 68
 69# test query string
 70wget -q -O- http://127.0.0.1:8080/index.html?foo | diff recursive/index.html -
 71
 72# test javascript
 73wget -q -O- http://127.0.0.1:8080/script.js > OUT
 74cat ../report.js recursive.expected/script.js | sed 's/@PREFIX@/\//g' | diff --strip-trailing-cr - OUT
 75wget -q -O- http://127.0.0.1:8080/1/1.js > OUT
 76cat ../report.js recursive.expected/1/1.js | sed 's/@PREFIX@/\//g' | diff --strip-trailing-cr - OUT
 77wget -q -O- http://127.0.0.1:8080/1/2/2.js > OUT
 78cat ../report.js recursive.expected/1/2/2.js | sed 's/@PREFIX@/\//g' | diff --strip-trailing-cr - OUT
 79
 80# test jscoverage
 81wget -q -O- http://127.0.0.1:8080/jscoverage.html | diff ../jscoverage.html -
 82wget -q -O- http://127.0.0.1:8080/jscoverage.css | diff ../jscoverage.css -
 83wget -q -O- http://127.0.0.1:8080/jscoverage-throbber.gif | diff ../jscoverage-throbber.gif -
 84wget -q -O- http://127.0.0.1:8080/jscoverage.js > OUT
 85echo -e 'jscoverage_isServer = true;\r' | cat ../jscoverage.js - | diff - OUT
 86
 87# load/store
 88wget --post-data='{}' -q -O- http://127.0.0.1:8080/jscoverage-store > /dev/null
 89echo -n '{}' | diff - DIR/jscoverage.json
 90diff ../jscoverage.html DIR/jscoverage.html
 91diff ../jscoverage.css DIR/jscoverage.css
 92diff ../jscoverage-throbber.gif DIR/jscoverage-throbber.gif
 93echo -e 'jscoverage_isReport = true;\r' | cat ../jscoverage.js - | diff - DIR/jscoverage.js
 94
 95# 404 not found
 96echo 404 > EXPECTED
 97! curl -f -w '%{http_code}\n' http://127.0.0.1:8080/missing 2> /dev/null > ACTUAL
 98diff EXPECTED ACTUAL
 99echo 404 > EXPECTED
100! curl -f -w '%{http_code}\n' http://127.0.0.1:8080/jscoverage-missing 2> /dev/null > ACTUAL
101diff EXPECTED ACTUAL
102
103# 403 forbidden
104echo 403 > EXPECTED
105! curl -f -w '%{http_code}\n' http://127.0.0.1:8080/../Makefile.am 2> /dev/null > ACTUAL
106diff EXPECTED ACTUAL
107
108## send it a proxy request
109#echo 400 > EXPECTED
110#! curl -f -w '%{http_code}\n' -x 127.0.0.1:8080 http://siliconforks.com/ 2> /dev/null > ACTUAL
111#diff EXPECTED ACTUAL
112
113# kill $server_pid
114shutdown
115
116rm -fr DIR
117mkdir DIR
118case `uname` in
119  MINGW*)
120    $VALGRIND jscoverage-server --no-highlight --port=8081 --document-root=recursive --report-dir=DIR --no-instrument=1/ &
121    ;;
122  *)
123    $VALGRIND jscoverage-server --no-highlight --port=8081 --document-root=recursive --report-dir=DIR --no-instrument=/1/ &
124    ;;
125esac
126server_pid=$!
127server_port=8081
128
129sleep $delay
130
131wget -q -O- http://127.0.0.1:8081/script.js > OUT
132cat ../report.js recursive.expected/script.js | sed 's/@PREFIX@/\//g' | diff --strip-trailing-cr - OUT
133wget -q -O- http://127.0.0.1:8081/1/1.js | diff --strip-trailing-cr recursive/1/1.js -
134wget -q -O- http://127.0.0.1:8081/1/2/2.js | diff --strip-trailing-cr recursive/1/2/2.js -
135
136# kill $server_pid
137shutdown
138
139$VALGRIND jscoverage-server --no-highlight --port 8082 --document-root recursive --report-dir DIR --no-instrument 1/ &
140server_pid=$!
141server_port=8082
142
143sleep $delay
144
145wget -q -O- http://127.0.0.1:8082/script.js > OUT
146cat ../report.js recursive.expected/script.js | sed 's/@PREFIX@/\//g' | diff --strip-trailing-cr - OUT
147wget -q -O- http://127.0.0.1:8082/1/1.js | diff --strip-trailing-cr recursive/1/1.js -
148wget -q -O- http://127.0.0.1:8082/1/2/2.js | diff --strip-trailing-cr recursive/1/2/2.js -
149
150# kill $server_pid
151shutdown
152
153$VALGRIND jscoverage-server --port 8080 --encoding iso-8859-1 --document-root javascript &
154server_pid=$!
155server_port=8080
156
157sleep $delay
158
159case "$character_encoding_support" in
160  yes)
161    wget -q -O- http://127.0.0.1:8080/javascript-iso-8859-1.js > OUT
162    cat ../report.js javascript.expected/javascript-iso-8859-1.js | sed 's/javascript-iso-8859-1.js/\/javascript-iso-8859-1.js/g' | diff --strip-trailing-cr - OUT
163    ;;
164  *)
165    echo 500 > EXPECTED
166    ! curl -f -w '%{http_code}\n' http://127.0.0.1:8080/javascript-iso-8859-1.js 2> /dev/null > ACTUAL
167    diff EXPECTED ACTUAL
168    ;;
169esac
170
171# kill $server_pid
172shutdown
173
174$VALGRIND jscoverage-server --no-highlight --port=8080 --encoding=utf-8 --document-root=javascript-utf-8 &
175server_pid=$!
176server_port=8080
177
178sleep $delay
179
180case "$character_encoding_support" in
181  yes)
182    wget -q -O- http://127.0.0.1:8080/javascript-utf-8.js > OUT
183    cat ../report.js javascript-utf-8.expected/javascript-utf-8.js | sed 's/javascript-utf-8.js/\/javascript-utf-8.js/g' | diff --strip-trailing-cr - OUT
184    ;;
185  *)
186    echo 500 > EXPECTED
187    ! curl -f -w '%{http_code}\n' http://127.0.0.1:8080/javascript-utf-8.js 2> /dev/null > ACTUAL
188    diff EXPECTED ACTUAL
189    ;;
190esac
191
192# kill $server_pid
193shutdown
194
195$VALGRIND jscoverage-server --port 8080 --encoding BOGUS --document-root javascript &
196server_pid=$!
197server_port=8080
198
199sleep $delay
200
201echo 500 > EXPECTED
202! curl -f -w '%{http_code}\n' http://127.0.0.1:8080/javascript-iso-8859-1.js 2> /dev/null > ACTUAL
203diff EXPECTED ACTUAL
204
205# kill $server_pid
206shutdown
207
208$VALGRIND jscoverage-server --port 8080 --encoding utf-8 --document-root javascript &
209server_pid=$!
210server_port=8080
211
212sleep $delay
213
214echo 500 > EXPECTED
215! curl -f -w '%{http_code}\n' http://127.0.0.1:8080/javascript-iso-8859-1.js 2> /dev/null > ACTUAL
216diff EXPECTED ACTUAL