Annotate tools/test-run-dev.

This commit is contained in:
Eklavya Sharma 2016-07-24 21:33:40 +05:30
parent 7edc38bbf7
commit 1e0a971178
2 changed files with 9 additions and 6 deletions

View File

@ -63,7 +63,6 @@ tools/deprecated/inject-messages/inject-messages
tools/deprecated/review tools/deprecated/review
tools/get-handlebar-vars tools/get-handlebar-vars
tools/minify-js tools/minify-js
tools/test-run-dev
tools/update-deployment tools/update-deployment
tools/zulip-export/zulip-export tools/zulip-export/zulip-export
""".split() """.split()

View File

@ -10,12 +10,14 @@ import signal
import subprocess import subprocess
from six.moves import range from six.moves import range
from typing import IO
TOOLS_DIR = os.path.dirname(os.path.abspath(__file__)) TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
def start_server(logfile): def start_server(logfile):
# type: (IO[str]) -> bool
failure = True failure = True
key = "Quit the server with CTRL-C." key = "Quit the server with CTRL-C."
for i in range(200): for i in range(200):
@ -30,6 +32,7 @@ def start_server(logfile):
def test_nagios(nagios_logfile): def test_nagios(nagios_logfile):
# type: (IO[str]) -> bool
ZULIP_DIR = os.path.join(TOOLS_DIR, '..') ZULIP_DIR = os.path.join(TOOLS_DIR, '..')
API_DIR = os.path.join(ZULIP_DIR, 'api') API_DIR = os.path.join(ZULIP_DIR, 'api')
os.chdir(API_DIR) os.chdir(API_DIR)
@ -55,6 +58,7 @@ def test_nagios(nagios_logfile):
def close_and_get_content(file_handle): def close_and_get_content(file_handle):
# type: (IO[str]) -> str
file_handle.seek(0) file_handle.seek(0)
content = file_handle.read() content = file_handle.read()
file_handle.close() file_handle.close()
@ -74,20 +78,20 @@ if __name__ == '__main__':
failure = start_server(logfile) failure = start_server(logfile)
failure = failure or not test_nagios(nagios_logfile) failure = failure or not test_nagios(nagios_logfile)
finally: finally:
logfile = close_and_get_content(logfile) log = close_and_get_content(logfile)
nagios_logfile = close_and_get_content(nagios_logfile) nagios_log = close_and_get_content(nagios_logfile)
run_dev.send_signal(signal.SIGINT) run_dev.send_signal(signal.SIGINT)
run_dev.wait() run_dev.wait()
if not failure and 'Traceback' in logfile + ' ' + nagios_logfile: if not failure and 'Traceback' in log + ' ' + nagios_log:
failure = True failure = True
if failure: if failure:
print("Development server is not working properly:") print("Development server is not working properly:")
print(logfile) print(log)
print("check_send_receive_time output:") print("check_send_receive_time output:")
print(nagios_logfile) print(nagios_log)
sys.exit(1) sys.exit(1)
else: else:
print("Development server is working properly.") print("Development server is working properly.")