--- trunk/tests/store-unreadable-json.sh 2009/02/18 16:08:33 427 +++ 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, 2009 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,7 +18,7 @@ set -e -. common.sh +. ./common.sh # skip on windows uname=`uname` @@ -39,22 +39,15 @@ trap 'cleanup' 0 1 2 3 15 -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 json_cmp TMP DIR/jscoverage.json @@ -62,5 +55,5 @@ 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