mirror of https://github.com/zulip/zulip.git
53 lines
1.5 KiB
Python
Executable File
53 lines
1.5 KiB
Python
Executable File
#!/usr/bin/env python2.7
|
|
|
|
import optparse
|
|
import os
|
|
import sys
|
|
|
|
import django
|
|
from django.conf import settings
|
|
from django.test.utils import get_runner
|
|
|
|
if __name__ == "__main__":
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
|
|
os.environ['DJANGO_SETTINGS_MODULE'] = 'zproject.test_settings'
|
|
# "-u" uses unbuffered IO, which is important when wrapping it in subprocess
|
|
os.environ['PYTHONUNBUFFERED'] = 'y'
|
|
django.setup()
|
|
|
|
parser = optparse.OptionParser()
|
|
parser.add_option('--nonfatal-errors', action="store_false", default=True,
|
|
dest="fatal_errors", help="Continue past test failures to run all tests")
|
|
parser.add_option('--coverage', dest='coverage',
|
|
action="store_true",
|
|
default=False, help='Compute test coverage.')
|
|
|
|
(options, args) = parser.parse_args()
|
|
if len(args) == 0:
|
|
suites = ["zerver"]
|
|
else:
|
|
suites = args
|
|
|
|
if options.coverage:
|
|
import coverage
|
|
cov = coverage.Coverage()
|
|
cov.start()
|
|
|
|
TestRunner = get_runner(settings)
|
|
test_runner = TestRunner()
|
|
failures = test_runner.run_tests(suites, fatal_errors=options.fatal_errors)
|
|
|
|
if options.coverage:
|
|
cov.stop()
|
|
cov.save()
|
|
print("Printing coverage data")
|
|
cov.report(show_missing=False)
|
|
cov.html_report()
|
|
print("HTML report saved to htmlcov/")
|
|
|
|
if failures:
|
|
print('FAILED!')
|
|
else:
|
|
print('DONE!')
|
|
sys.exit(bool(failures))
|