casper: Fix issues with server autoreloading on save.

This fixes an issue where if you saved a Python file (even just
changing whitespace) while casper tests were running, the Tornado
server being used would restart, triggering a confusing error like
this:

ReferenceError: Can't find variable: $
Traceback:
  undefined:2
  :4
Suite explicitly interrupted without any message given.
This commit is contained in:
Tim Abbott 2017-03-17 20:43:27 -07:00
parent af8732fd42
commit 25488b550f
4 changed files with 12 additions and 3 deletions

View File

@ -96,10 +96,13 @@ if options.interface is None:
elif options.interface == "": elif options.interface == "":
options.interface = None options.interface = None
runserver_args = []
base_port = 9991 base_port = 9991
if options.test: if options.test:
base_port = 9981 base_port = 9981
settings_module = "zproject.test_settings" settings_module = "zproject.test_settings"
# Don't auto-reload when running casper tests
runserver_args = ['--noreload']
else: else:
settings_module = "zproject.settings" settings_module = "zproject.settings"
@ -154,7 +157,7 @@ pid_file.close()
# zulip/urls.py. # zulip/urls.py.
cmds = [['./tools/compile-handlebars-templates', 'forever'], cmds = [['./tools/compile-handlebars-templates', 'forever'],
['./manage.py', 'runserver'] + ['./manage.py', 'runserver'] +
manage_args + ['127.0.0.1:%d' % (django_port,)], manage_args + runserver_args + ['127.0.0.1:%d' % (django_port,)],
['env', 'PYTHONUNBUFFERED=1', './manage.py', 'runtornado'] + ['env', 'PYTHONUNBUFFERED=1', './manage.py', 'runtornado'] +
manage_args + ['127.0.0.1:%d' % (tornado_port,)], manage_args + ['127.0.0.1:%d' % (tornado_port,)],
['./tools/run-dev-queue-processors'] + manage_args, ['./tools/run-dev-queue-processors'] + manage_args,

View File

@ -19,5 +19,6 @@ def create_tornado_application():
return tornado.web.Application(([(url, AsyncDjangoHandler) for url in urls] + return tornado.web.Application(([(url, AsyncDjangoHandler) for url in urls] +
get_sockjs_router().urls), get_sockjs_router().urls),
debug=settings.DEBUG, debug=settings.DEBUG,
autoreload=settings.AUTORELOAD,
# Disable Tornado's own request logging, since we have our own # Disable Tornado's own request logging, since we have our own
log_function=lambda x: None) log_function=lambda x: None)

View File

@ -363,6 +363,7 @@ ZILENCER_ENABLED = 'zilencer' in INSTALLED_APPS
# We override the port number when running frontend tests. # We override the port number when running frontend tests.
TORNADO_SERVER = 'http://127.0.0.1:9993' TORNADO_SERVER = 'http://127.0.0.1:9993'
RUNNING_INSIDE_TORNADO = False RUNNING_INSIDE_TORNADO = False
AUTORELOAD = DEBUG
######################################################################## ########################################################################
# DATABASE CONFIGURATION # DATABASE CONFIGURATION

View File

@ -96,8 +96,12 @@ CACHES['database'] = {
} }
} }
# Use local memory cache for backend tests.
if not CASPER_TESTS: if CASPER_TESTS:
# Don't auto-restart Tornado server during casper tests
AUTORELOAD = False
else:
# Use local memory cache for backend tests.
CACHES['default'] = { CACHES['default'] = {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache' 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'
} }