forked from zulip/zulip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-run-dev
executable file
·55 lines (44 loc) · 1.43 KB
/
test-run-dev
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python3
import os
import signal
import subprocess
import sys
import time
from typing import Tuple
from lib import sanity_check
sanity_check.check_venv(__file__)
TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
def start_server(logfile_name: str) -> Tuple[bool, str]:
failure = True
key = "Quit the server with CTRL-C."
datalog = []
with open(logfile_name, 'rb', buffering=0) as logfile:
for i in range(200):
time.sleep(0.5)
print("{}. Polling run-dev...".format(i))
new_data = logfile.read().decode()
if new_data:
datalog.append(new_data)
if key in ''.join(datalog):
failure = False
break
return failure, ''.join(datalog)
if __name__ == '__main__':
print("Testing development server start!")
logfile_name = '/tmp/run-dev-output'
with open(logfile_name, 'wb', buffering=0) as logfile:
run_dev = subprocess.Popen(
[os.path.join(TOOLS_DIR, "run-dev.py")],
stdout=logfile, stderr=subprocess.STDOUT)
failure, log = start_server(logfile_name)
run_dev.send_signal(signal.SIGINT)
run_dev.wait()
if 'Traceback' in log:
failure = True
if failure:
print("Development server is not working properly:")
print(log)
sys.exit(1)
else:
print("Development server is working properly.")
sys.exit(0)