Question

CasperJS exists with status code zero onto a bash script regardless of whether tests fail. Spent quite some time figuring out why it's always zero

Était-ce utile?

La solution

ended up writing the following script. Hopefully it's useful to some people.

EXIT_STATUS=0
SOURCE="${BASH_SOURCE[0]}"
DIR="$( dirname "$SOURCE" )"

echo 'killing processes using port 9999'
PORT_NUMBER=9999
lsof -i tcp:${PORT_NUMBER} | awk 'NR!=1 {print $2}' | xargs kill 

echo 'starting server on 9999'
grunt connect:dist_server &
SERVER_PID=$!
echo 'server pid:' ${SERVER_PID}

echo 'waiting for server to start'
sleep 1

echo 'running casperjs tests'
FAILURES=$($YOUR_CASPERJS_DIR/casperjs/bin/casperjs test --fail-fast --host='http://localhost:9999/' --engine=slimerjs --log-level='debug' --verbose --local-storage-quota=100 `pwd`/$1 | grep 'FAIL')

echo 'failures grepped:' ${FAILURES}


echo 'stopping server'
kill ${SERVER_PID}

if [ "$FAILURES" == "" ]; then
  EXIT_STATUS=0
else 
  EXIT_STATUS=1
fi

echo 'setting exit status' $EXIT_STATUS

exit $EXIT_STATUS

#--log-level='debug' --verbose
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top