PageRenderTime 143ms CodeModel.GetById 60ms app.highlight 12ms RepoModel.GetById 49ms app.codeStats 0ms

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

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs
Shell | 143 lines | 85 code | 26 blank | 32 comment | 1 complexity | 39bdefc000fc9a3c4f270f7cbf79d1ef MD5 | raw file
  1#!/bin/sh
  2#    proxy.sh - test jscoverage-server --proxy
  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
 26shutdown_perl() {
 27  wget -q -O- --post-data= http://127.0.0.1:8000/perl-shutdown > /dev/null
 28  wait $origin_server_pid
 29}
 30
 31cleanup() {
 32  rm -fr EXPECTED ACTUAL DIR OUT
 33  shutdown
 34  shutdown_perl
 35}
 36
 37trap 'cleanup' 0 1 2 3 15
 38
 39export PATH=.:..:$PATH
 40
 41if [ -z "$VALGRIND" ]
 42then
 43  delay=0.2
 44else
 45  delay=2
 46fi
 47
 48cd recursive
 49perl ../server.pl > /dev/null 2> /dev/null &
 50origin_server_pid=$!
 51cd ..
 52
 53rm -fr DIR
 54mkdir DIR
 55$VALGRIND jscoverage-server --no-highlight --proxy --report-dir=DIR > OUT 2> ERR &
 56proxy_server_pid=$!
 57proxy_server_port=8080
 58
 59sleep $delay
 60
 61wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/index.html | diff recursive/index.html -
 62wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/style.css | diff recursive/style.css -
 63wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/unix.txt | diff recursive/unix.txt -
 64wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/windows.txt | diff recursive/windows.txt -
 65wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/image.png | diff recursive/image.png -
 66wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/x | diff recursive/x -
 67wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/1/1.html | diff recursive/1/1.html -
 68wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/1/1.css | diff recursive/1/1.css -
 69wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/1/2/2.html | diff recursive/1/2/2.html -
 70wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/1/2/2.css | diff recursive/1/2/2.css -
 71
 72# test localhost
 73wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://localhost:8000/index.html | diff recursive/index.html -
 74
 75# test actual hostname
 76h=`hostname`
 77wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://${h}:8000/index.html | diff recursive/index.html -
 78
 79# test query string
 80wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/index.html?foo | diff recursive/index.html -
 81
 82# test POST
 83wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' --post-file=recursive/index.html http://127.0.0.1:8000/ | diff recursive/index.html -
 84
 85# test javascript
 86wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/script.js > OUT
 87cat ../report.js recursive.expected/script.js | sed 's/@PREFIX@/http:\/\/127.0.0.1:8000\//g' | diff --strip-trailing-cr - OUT
 88wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/1/1.js > OUT
 89cat ../report.js recursive.expected/1/1.js | sed 's/@PREFIX@/http:\/\/127.0.0.1:8000\//g' | diff --strip-trailing-cr - OUT
 90wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/1/2/2.js > OUT
 91cat ../report.js recursive.expected/1/2/2.js | sed 's/@PREFIX@/http:\/\/127.0.0.1:8000\//g' | diff --strip-trailing-cr - OUT
 92
 93## test jscoverage
 94wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://siliconforks.com/jscoverage.html | diff ../jscoverage.html -
 95wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://siliconforks.com/jscoverage.css | diff ../jscoverage.css -
 96wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://siliconforks.com/jscoverage-throbber.gif | diff ../jscoverage-throbber.gif -
 97wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://siliconforks.com/jscoverage.js > OUT
 98echo -e 'jscoverage_isServer = true;\r' | cat ../jscoverage.js - | diff - OUT
 99
100# load/store
101wget -q -O- -e 'http_proxy=http://127.0.0.1:8080/' --post-data='{}' http://siliconforks.com/jscoverage-store > /dev/null
102echo -n '{}' | diff - DIR/jscoverage.json
103diff ../jscoverage.html DIR/jscoverage.html
104diff ../jscoverage.css DIR/jscoverage.css
105diff ../jscoverage-throbber.gif DIR/jscoverage-throbber.gif
106echo -e 'jscoverage_isReport = true;\r' | cat ../jscoverage.js - | diff - DIR/jscoverage.js
107
108# send it an FTP request
109echo 400 > EXPECTED
110! curl -f -w '%{http_code}\n' -x 127.0.0.1:8080 ftp://ftp.example.com 2> /dev/null > ACTUAL
111diff EXPECTED ACTUAL
112
113# nonexistent domain
114echo 504 > EXPECTED
115! curl -f -w '%{http_code}\n' -x 127.0.0.1:8080 http://nonexistent 2> /dev/null > ACTUAL
116diff EXPECTED ACTUAL
117
118# 404 not found
119echo 404 > EXPECTED
120! curl -f -w '%{http_code}\n' -x 127.0.0.1:8080 http://127.0.0.1:8000/missing 2> /dev/null > ACTUAL
121diff EXPECTED ACTUAL
122echo 404 > EXPECTED
123! curl -f -w '%{http_code}\n' -x 127.0.0.1:8080 http://siliconforks.com/jscoverage-missing 2> /dev/null > ACTUAL
124diff EXPECTED ACTUAL
125
126## send it a server request
127#echo 400 > EXPECTED
128#! curl -f -w '%{http_code}\n' http://127.0.0.1:8080/ 2> /dev/null > ACTUAL
129#diff EXPECTED ACTUAL
130
131# kill $proxy_server_pid
132shutdown
133
134$VALGRIND jscoverage-server --no-highlight --port=8081 --proxy --report-dir=DIR --no-instrument=http://127.0.0.1:8000/1/ &
135proxy_server_pid=$!
136proxy_server_port=8081
137
138sleep $delay
139
140wget -q -O- -e 'http_proxy=http://127.0.0.1:8081/' http://127.0.0.1:8000/script.js > OUT
141cat ../report.js recursive.expected/script.js | sed 's/@PREFIX@/http:\/\/127.0.0.1:8000\//g' | diff --strip-trailing-cr - OUT
142wget -q -O- -e 'http_proxy=http://127.0.0.1:8081/' http://127.0.0.1:8000/1/1.js | diff --strip-trailing-cr recursive/1/1.js -
143wget -q -O- -e 'http_proxy=http://127.0.0.1:8081/' http://127.0.0.1:8000/1/2/2.js | diff --strip-trailing-cr recursive/1/2/2.js -