Files
zulip/zephyr/tests/frontend/run
Tim Abbott 52589ca6fb Fix running "./manage.py test zephyr --settings=humbug.test_settings"
Previously it wouldn't work due to using the wrong port numbers.

This commit also has the side effect of fixing the fact that our
frontend tests would send real emails and log events to the real
message log.

(imported from commit f2cf400e6061c089627acba2759d588981ecf5bb)
2013-01-10 16:59:36 -05:00

53 lines
1.4 KiB
Python
Executable File

#!/usr/bin/env python
import subprocess
import requests
import time
import sys
import os
from os import path
os.environ["TORNADO_SERVER"] = "http://localhost:9983"
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)
def assert_server_running():
# Get the exit code of the server, or None if it is still running.
if server.poll() is not None:
raise RuntimeError, 'Server died unexpectedly! Check zephyr/tests/frontend/server.log'
def server_is_up():
assert_server_running()
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
ret = 1
try:
# Wait for the server to start up.
sys.stdout.write('Waiting for test server')
while not server_is_up():
sys.stdout.write('.')
sys.stdout.flush()
time.sleep(0.1)
sys.stdout.write('\n')
ret = subprocess.call(
'zephyr/tests/frontend/casperjs/bin/casperjs test zephyr/tests/frontend/tests',
shell=True)
finally:
assert_server_running()
server.terminate()
sys.exit(ret)