Add tools/test-lib.
This starts to add direct test coverage on zulip_bots/zulip_bots/lib.py. It is not yet integrated into tools/test-main.
This commit is contained in:
parent
3e135b8e1e
commit
efeac92d42
3 changed files with 97 additions and 0 deletions
|
@ -28,6 +28,8 @@ exclude = [
|
|||
# Excluded out of laziness:
|
||||
"zulip_bots/zulip_bots/terminal.py",
|
||||
"zulip_bots/zulip_bots/simple_lib.py",
|
||||
"zulip_bots/zulip_bots/lib_tests.py",
|
||||
"tools/test-lib",
|
||||
]
|
||||
|
||||
parser = argparse.ArgumentParser(description="Run mypy on files tracked by git.")
|
||||
|
|
35
tools/test-lib
Executable file
35
tools/test-lib
Executable file
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import coverage
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
from importlib import import_module
|
||||
|
||||
def run_all():
|
||||
TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
ROOT_DIR = os.path.abspath(os.path.join(TOOLS_DIR, '..'))
|
||||
BOTS_DIR = os.path.join(ROOT_DIR, 'zulib_bots')
|
||||
sys.path.insert(0, BOTS_DIR)
|
||||
|
||||
cov = coverage.Coverage(config_file="tools/.coveragerc")
|
||||
cov.start()
|
||||
|
||||
module = import_module('zulip_bots.lib_tests')
|
||||
suite = unittest.defaultTestLoader.loadTestsFromModule(module)
|
||||
|
||||
suite = unittest.TestSuite([suite])
|
||||
runner = unittest.TextTestRunner(verbosity=2)
|
||||
result = runner.run(suite)
|
||||
if result.failures or result.errors:
|
||||
sys.exit(1)
|
||||
|
||||
cov.stop()
|
||||
cov.data_suffix = False # Disable suffix so that filename is .coverage
|
||||
cov.save()
|
||||
cov.html_report()
|
||||
print("HTML report saved under directory 'htmlcov'.")
|
||||
|
||||
if __name__ == '__main__':
|
||||
run_all()
|
Loading…
Add table
Add a link
Reference in a new issue