1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-10 20:49:17 +00:00

log test progress

This commit is contained in:
deadc0de6
2021-10-21 21:36:44 +02:00
parent b225812702
commit 7aa4832ce0

View File

@@ -14,19 +14,24 @@ from halo import Halo
MAX_JOBS = 10 MAX_JOBS = 10
LOG_FILE = '/tmp/dotdrop-tests-launcher.log'
def run_test(path): def run_test(logfd, path):
cur = os.path.dirname(sys.argv[0]) cur = os.path.dirname(sys.argv[0])
name = os.path.basename(path) name = os.path.basename(path)
path = os.path.join(cur, name) path = os.path.join(cur, name)
if logfd:
logfd.write('starting test {}\n'.format(path))
p = subprocess.Popen(path, shell=False, p = subprocess.Popen(path, shell=False,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT) stderr=subprocess.STDOUT)
out, _ = p.communicate() out, _ = p.communicate()
out = out.decode() out = out.decode()
r = p.returncode == 0 r = p.returncode == 0
if logfd:
logfd.write('done test {}\n'.format(path))
reason = 'returncode' reason = 'returncode'
if 'Traceback' in out: if 'Traceback' in out:
r = False r = False
@@ -53,17 +58,23 @@ def main():
tests = get_tests() tests = get_tests()
fd = open(LOG_FILE, 'w')
fd.write('start with {} jobs\n'.format(MAX_JOBS))
fd.flush()
print() print()
spinner = Halo(text='Testing', spinner='bouncingBall') spinner = Halo(text='Testing', spinner='bouncingBall')
spinner.start() spinner.start()
with futures.ThreadPoolExecutor(max_workers=MAX_JOBS) as ex: with futures.ThreadPoolExecutor(max_workers=MAX_JOBS) as ex:
wait_for = [] wait_for = []
for test in tests: for test in tests:
j = ex.submit(run_test, test) j = ex.submit(run_test, fd, test)
wait_for.append(j) wait_for.append(j)
fd.flush()
for f in futures.as_completed(wait_for): for f in futures.as_completed(wait_for):
r, reason, p, log = f.result() r, reason, p, log = f.result()
fd.flush()
if not r: if not r:
ex.shutdown(wait=False) ex.shutdown(wait=False)
for x in wait_for: for x in wait_for:
@@ -71,6 +82,7 @@ def main():
print() print()
print(log) print(log)
print('test {} failed ({})'.format(p, reason)) print('test {} failed ({})'.format(p, reason))
fd.close()
return False return False
#else: #else:
# sys.stdout.write('.') # sys.stdout.write('.')
@@ -78,6 +90,8 @@ def main():
sys.stdout.write('\n') sys.stdout.write('\n')
spinner.stop() spinner.stop()
print() print()
fd.write('done with {} jobs\n'.format(MAX_JOBS))
fd.close()
return True return True