2017-02-10 07:13:03 +00:00
|
|
|
import getopt
|
|
|
|
import os
|
2017-04-18 17:37:10 +00:00
|
|
|
import sys
|
2017-02-10 07:13:03 +00:00
|
|
|
|
|
|
|
opts, args = getopt.getopt(sys.argv[1:], "cm:", ["coverage=", "module="])
|
|
|
|
|
|
|
|
is_coverage = False
|
|
|
|
test_module = ""
|
|
|
|
setting = "oj.settings"
|
|
|
|
|
|
|
|
for opt, arg in opts:
|
2017-02-12 11:32:41 +00:00
|
|
|
if opt in ["-c", "--coverage"]:
|
2017-02-10 07:13:03 +00:00
|
|
|
is_coverage = True
|
2017-02-12 11:32:41 +00:00
|
|
|
if opt in ["-m", "--module"]:
|
2017-02-10 07:13:03 +00:00
|
|
|
test_module = arg
|
|
|
|
|
|
|
|
print("Coverage: {cov}".format(cov=is_coverage))
|
|
|
|
print("Module: {mod}".format(mod=(test_module if test_module else "All")))
|
|
|
|
|
|
|
|
print("running flake8...")
|
|
|
|
if os.system("flake8 --statistics ."):
|
|
|
|
exit()
|
|
|
|
|
2017-11-23 13:12:37 +00:00
|
|
|
ret = os.system("coverage run --include=\"$PWD/*\" manage.py test {module} --settings={setting}".format(module=test_module, setting=setting))
|
2017-02-10 07:13:03 +00:00
|
|
|
|
|
|
|
if not ret and is_coverage:
|
|
|
|
os.system("coverage html && open htmlcov/index.html")
|