Skip to content

Instantly share code, notes, and snippets.

@phuesler
Last active December 21, 2015 11:19
Show Gist options
  • Save phuesler/6298175 to your computer and use it in GitHub Desktop.
Save phuesler/6298175 to your computer and use it in GitHub Desktop.
#!/bin/bash
# save the project root. it seems that the
# python webserver needs absolute paths
PROJECT_ROOT=`pwd`
# We will Log the webserver's output to a log file
# Make sure the directory is there and we have a file
# to append to
mkdir -p log
touch log/webserver.log
# Webserver listen host 127.0.0.1 and port 80000
# change into the directory where we serve our files
cd $PROJECT_ROOT
python -m SimpleHTTPServer >> $PROJECT_ROOT/log/webserver.log 2>&1 &
# capture the pid of our server so that we can kill it later
WEB_PID=$!
# wait for the server to be ready
sleep 1
# test out if it works
curl localhost:8000
# this is where your test script goes
echo "add your test runner script here, e.g:'./bin/test $*'"
# caputure return code of your test script so we can return it later.
# This is imporant for ci system to determine success or failure
# of a test run
TEST_EXIT=$?
# kill the webserver
kill $WEB_PID
# return the exit code of our test script
exit $TEST_EXIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment