2012-11-09 21:03:57 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
import subprocess
|
2012-11-13 23:54:08 +01:00
|
|
|
import requests
|
2012-11-09 21:03:57 +01:00
|
|
|
import time
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
from os import path
|
|
|
|
|
|
|
|
os.chdir(path.join(path.dirname(__file__), '../../..'))
|
|
|
|
|
|
|
|
subprocess.check_call('zephyr/tests/generate-fixtures')
|
|
|
|
|
|
|
|
log = open('zephyr/tests/frontend/server.log', 'w')
|
|
|
|
|
|
|
|
# Run this not through the shell, so that we have the actual PID.
|
|
|
|
server = subprocess.Popen(('tools/run-dev.py', '--test'),
|
|
|
|
stdout=log, stderr=log)
|
|
|
|
|
2012-11-13 23:54:08 +01:00
|
|
|
def server_is_up():
|
|
|
|
try:
|
|
|
|
# We could get a 501 error if the reverse proxy is up but the Django app isn't.
|
|
|
|
return requests.get('http://localhost:9981/accounts/home').status_code == 200
|
|
|
|
except:
|
|
|
|
return False
|
|
|
|
|
2012-11-14 00:01:43 +01:00
|
|
|
ret = 1
|
2012-11-09 21:03:57 +01:00
|
|
|
|
2012-11-14 00:01:43 +01:00
|
|
|
try:
|
|
|
|
# Wait for the server to start up.
|
|
|
|
while not server_is_up():
|
|
|
|
print 'Waiting for test server'
|
|
|
|
time.sleep(0.1)
|
2012-11-09 21:03:57 +01:00
|
|
|
|
2012-11-14 00:01:43 +01:00
|
|
|
ret = subprocess.call(
|
|
|
|
'zephyr/tests/frontend/casperjs/bin/casperjs zephyr/tests/frontend/tests.js',
|
|
|
|
shell=True)
|
|
|
|
finally:
|
|
|
|
server.terminate()
|
2012-11-09 21:03:57 +01:00
|
|
|
|
|
|
|
sys.exit(ret)
|