coverage integration, default .coveragerc and .travis.yml ready for coveralls.io

This commit is contained in:
niphlod
2013-04-15 21:50:36 +02:00
parent 40918f44fd
commit f9315a8cc7
3 changed files with 46 additions and 13 deletions
+30 -10
View File
@@ -62,22 +62,34 @@ if not sys.version[:3] in ['2.4', '2.5', '2.6', '2.7']:
logger = logging.getLogger("web2py")
def run_system_tests():
def run_system_tests(options):
"""
Runs unittests for gluon.tests
"""
import subprocess
major_version = sys.version_info[0]
minor_version = sys.version_info[1]
print "minor_version = %r" % minor_version
if major_version == 2:
if minor_version in (5, 6):
print "Python 2.5 or 2.6"
ret = os.system("PYTHONPATH=. unit2 -v gluon.tests")
sys.stderr.write("Python 2.5 or 2.6\n")
ret = subprocess.call(['unit2', '-v', 'gluon.tests'])
elif minor_version in (7,):
print "Python 2.7"
ret = os.system("PYTHONPATH=. python -m unittest -v gluon.tests")
call_args = [sys.executable, '-m', 'unittest', '-v', 'gluon.tests']
if options.with_coverage:
try:
import coverage
coverage_config = os.path.join('gluon', 'tests', '.coveragerc')
call_args = ['coverage', 'run', '--rcfile=%s' % coverage_config,
'-m', 'unittest', '-v', 'gluon.tests']
except:
sys.stderr.write('Coverage was not installed, skipping\n')
sys.stderr.write("Python 2.7\n")
ret = subprocess.call(call_args)
else:
print "unknown python 2.x version"
sys.stderr.write("unknown python 2.x version\n")
ret = 256
else:
print "Only Python 2.x supported."
sys.stderr.write("Only Python 2.x supported.\n")
ret = 256
sys.exit(ret and 1)
@@ -902,7 +914,15 @@ def console():
dest='run_system_tests',
default=False,
help=msg)
msg = ('adds coverage reporting (needs --run_system_tests), '
'python 2.7 and the coverage module installed')
parser.add_option('--with_coverage',
action='store_true',
dest='with_coverage',
default=False,
help=msg)
if '-A' in sys.argv:
k = sys.argv.index('-A')
elif '--args' in sys.argv:
@@ -923,7 +943,7 @@ def console():
options.ips = []
if options.run_system_tests:
run_system_tests()
run_system_tests(options)
if options.quiet:
capture = cStringIO.StringIO()