--- trunk/tests/store-unreadable-json.sh 2008/09/21 18:42:02 181 +++ trunk/tests/store-unreadable-json.sh 2010/09/24 20:35:36 610 @@ -1,6 +1,6 @@ #!/bin/sh # store-unreadable-json.sh - test store when jscoverage.json is not readable -# Copyright (C) 2008 siliconforks.com +# Copyright (C) 2008, 2009, 2010 siliconforks.com # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,6 +18,8 @@ set -e +. ./common.sh + # skip on windows uname=`uname` case "$uname" in @@ -37,30 +39,21 @@ trap 'cleanup' 0 1 2 3 15 -export PATH=.:..:../js:$PATH - -if [ -z "$VALGRIND" ] -then - delay=0.2 -else - delay=2 -fi - rm -fr DIR -$VALGRIND jscoverage-server --no-highlight --document-root=recursive --report-dir=DIR > OUT 2> ERR & +server_port=`perl unused-port.pl` +$VALGRIND jscoverage-server --port=$server_port --no-highlight --document-root=recursive --report-dir=DIR > OUT 2> ERR & server_pid=$! -server_port=8080 -sleep $delay +wait_for_server http://127.0.0.1:${server_port}/jscoverage.html cat store.json | sed "s/@PREFIX@/\\//g" > TMP -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:${server_port}/jscoverage-store > /dev/null cat store.expected.json | sed "s/@PREFIX@/\\//g" > TMP -js json-cmp.js TMP DIR/jscoverage.json +json_cmp TMP DIR/jscoverage.json chmod -r DIR/jscoverage.json cat store.json | sed "s/@PREFIX@/\\//g" > TMP echo 500 > EXPECTED -! curl -d @TMP -f -w '%{http_code}\n' http://127.0.0.1:8080/jscoverage-store 2> /dev/null > ACTUAL +! curl -d @TMP -f -w '%{http_code}\n' http://127.0.0.1:${server_port}/jscoverage-store 2> /dev/null > ACTUAL diff EXPECTED ACTUAL