Files
zulip/tools/test-tools
Greg Price 137c0e65bb tools: Revert to Python 2 typing syntax for now.
This reverts commit 66261f1cc.  See parent commit for reason; here,
provision worked but `tools/run-dev.py` would give errors.

We need to figure out a test that reproduces these issues, then make a
version of these changes that keeps that test working, before we
re-merge them.
2017-12-13 10:38:15 -08:00

50 lines
1.4 KiB
Python
Executable File

#!/usr/bin/env python3
import argparse
import os
import sys
import unittest
# check for the venv
from lib import sanity_check
sanity_check.check_venv(__file__)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--coverage', dest='coverage',
action="store_true",
default=False, help='compute test coverage')
args = parser.parse_args()
def dir_join(dir1, dir2):
# type: (str, str) -> str
return os.path.abspath(os.path.join(dir1, dir2))
tools_dir = os.path.dirname(os.path.abspath(__file__))
root_dir = dir_join(tools_dir, '..')
tools_test_dir = dir_join(tools_dir, 'tests')
sys.path.insert(0, root_dir)
loader = unittest.TestLoader()
if args.coverage:
import coverage
cov = coverage.Coverage(branch=True, omit=["*/zulip-venv-cache/*", dir_join(tools_test_dir, "*")])
cov.start()
suite = loader.discover(start_dir=tools_test_dir, top_level_dir=root_dir)
runner = unittest.TextTestRunner(verbosity=2)
result = runner.run(suite)
if result.errors or result.failures:
raise Exception('Test failed!')
if args.coverage:
cov.stop()
cov.save()
cov.html_report(directory='var/tools_coverage')
print("HTML report saved to var/tools_coverage")
print('SUCCESS')