phantomjs.runner.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/bash
  2. # sanity check to make sure node and phantomjs exist in the PATH
  3. hash /usr/bin/env node &> /dev/null
  4. if [ $? -eq 1 ]; then
  5. echo "ERROR: node is not installed"
  6. echo "Please visit http://www.nodejs.org/"
  7. exit 1
  8. fi
  9. hash /usr/bin/env phantomjs &> /dev/null
  10. if [ $? -eq 1 ]; then
  11. echo "ERROR: phantomjs is not installed"
  12. echo "Please visit http://www.phantomjs.org/"
  13. exit 1
  14. fi
  15. # sanity check number of args
  16. if [ $# -lt 1 ]
  17. then
  18. echo "Usage: `basename $0` path_to_runner.html"
  19. echo
  20. exit 1
  21. fi
  22. SCRIPTDIR=$(dirname `perl -e 'use Cwd "abs_path";print abs_path(shift)' $0`)
  23. TESTFILE=""
  24. while (( "$#" )); do
  25. if [ ${1:0:7} == "http://" -o ${1:0:8} == "https://" ]; then
  26. TESTFILE="$TESTFILE $1"
  27. else
  28. TESTFILE="$TESTFILE `perl -e 'use Cwd "abs_path";print abs_path(shift)' $1`"
  29. fi
  30. shift
  31. done
  32. # cleanup previous test runs
  33. cd $SCRIPTDIR
  34. rm -f *.xml
  35. # make sure phantomjs submodule is initialized
  36. cd ..
  37. git submodule update --init
  38. # fire up the phantomjs environment and run the test
  39. cd $SCRIPTDIR
  40. /usr/bin/env phantomjs $SCRIPTDIR/phantomjs-testrunner.js $TESTFILE