zulip/tools/test-tools
Greg Price a099e698e2 py3: Switch almost all shebang lines to use python3.
This causes `upgrade-zulip-from-git`, as well as a no-option run of
`tools/build-release-tarball`, to produce a Zulip install running
Python 3, rather than Python 2.  In particular this means that the
virtualenv we create, in which all application code runs, is Python 3.

One shebang line, on `zulip-ec2-configure-interfaces`, explicitly
keeps Python 2, and at least one external ops script, `wal-e`, also
still runs on Python 2.  See discussion on the respective previous
commits that made those explicit.  There may also be some other
third-party scripts we use, outside of this source tree and running
outside our virtualenv, that still run on Python 2.
2017-08-16 17:54:43 -07:00

52 lines
1.5 KiB
Python
Executable File

#!/usr/bin/env python3
from __future__ import absolute_import
from __future__ import print_function
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) # type: ignore # https://github.com/python/typeshed/issues/372
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')