coverage integration, default .coveragerc and .travis.yml ready for coveralls.io
This commit is contained in:
+9
-2
@@ -5,12 +5,16 @@ python:
|
|||||||
- '2.6'
|
- '2.6'
|
||||||
- '2.7'
|
- '2.7'
|
||||||
- 'pypy'
|
- 'pypy'
|
||||||
|
install:
|
||||||
|
- pip install -e . --use-mirrors
|
||||||
env:
|
env:
|
||||||
- DB=sqlite:memory
|
- DB=sqlite:memory
|
||||||
- DB=mysql://root:@localhost/test_w2p
|
- DB=mysql://root:@localhost/test_w2p
|
||||||
- DB=postgres://postgres:@localhost/test_w2p
|
- DB=postgres://postgres:@localhost/test_w2p
|
||||||
before_script:
|
before_script:
|
||||||
- pip install unittest2
|
- if [[ $TRAVIS_PYTHON_VERSION != '2.7' ]]; then pip install --use-mirrors unittest2; fi
|
||||||
|
- if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then pip install --use-mirrors coverage; fi;
|
||||||
|
- if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then pip install --use-mirrors python-coveralls; fi
|
||||||
- if [[ $DB == postgres* ]]; then pip install --use-mirrors psycopg2; fi;
|
- if [[ $DB == postgres* ]]; then pip install --use-mirrors psycopg2; fi;
|
||||||
- if [[ $TRAVIS_PYTHON_VERSION == '2.5' ]]; then pip install --use-mirrors pysqlite; fi
|
- if [[ $TRAVIS_PYTHON_VERSION == '2.5' ]]; then pip install --use-mirrors pysqlite; fi
|
||||||
- if [[ $DB == mysql* ]]; then mysql -e 'create database test_w2p;'; fi
|
- if [[ $DB == mysql* ]]; then mysql -e 'create database test_w2p;'; fi
|
||||||
@@ -25,7 +29,10 @@ matrix:
|
|||||||
- python: 'pypy'
|
- python: 'pypy'
|
||||||
env: DB=mysql://root:@localhost/test_w2p
|
env: DB=mysql://root:@localhost/test_w2p
|
||||||
|
|
||||||
script: PYTHONPATH=. unit2 -v gluon.tests
|
script: export COVERAGE_PROCESS_START=gluon/tests/.coveragerc; ./web2py.py --run_system_tests --with_coverage
|
||||||
|
after_success:
|
||||||
|
- if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then coverage combine; fi
|
||||||
|
- if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then coveralls --config_file=gluon/tests/.coveragerc; fi
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
email: true
|
email: true
|
||||||
|
|||||||
+29
-9
@@ -62,22 +62,34 @@ if not sys.version[:3] in ['2.4', '2.5', '2.6', '2.7']:
|
|||||||
logger = logging.getLogger("web2py")
|
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]
|
major_version = sys.version_info[0]
|
||||||
minor_version = sys.version_info[1]
|
minor_version = sys.version_info[1]
|
||||||
print "minor_version = %r" % minor_version
|
|
||||||
if major_version == 2:
|
if major_version == 2:
|
||||||
if minor_version in (5, 6):
|
if minor_version in (5, 6):
|
||||||
print "Python 2.5 or 2.6"
|
sys.stderr.write("Python 2.5 or 2.6\n")
|
||||||
ret = os.system("PYTHONPATH=. unit2 -v gluon.tests")
|
ret = subprocess.call(['unit2', '-v', 'gluon.tests'])
|
||||||
elif minor_version in (7,):
|
elif minor_version in (7,):
|
||||||
print "Python 2.7"
|
call_args = [sys.executable, '-m', 'unittest', '-v', 'gluon.tests']
|
||||||
ret = os.system("PYTHONPATH=. python -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:
|
else:
|
||||||
print "unknown python 2.x version"
|
sys.stderr.write("unknown python 2.x version\n")
|
||||||
ret = 256
|
ret = 256
|
||||||
else:
|
else:
|
||||||
print "Only Python 2.x supported."
|
sys.stderr.write("Only Python 2.x supported.\n")
|
||||||
ret = 256
|
ret = 256
|
||||||
sys.exit(ret and 1)
|
sys.exit(ret and 1)
|
||||||
|
|
||||||
@@ -903,6 +915,14 @@ def console():
|
|||||||
default=False,
|
default=False,
|
||||||
help=msg)
|
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:
|
if '-A' in sys.argv:
|
||||||
k = sys.argv.index('-A')
|
k = sys.argv.index('-A')
|
||||||
elif '--args' in sys.argv:
|
elif '--args' in sys.argv:
|
||||||
@@ -923,7 +943,7 @@ def console():
|
|||||||
options.ips = []
|
options.ips = []
|
||||||
|
|
||||||
if options.run_system_tests:
|
if options.run_system_tests:
|
||||||
run_system_tests()
|
run_system_tests(options)
|
||||||
|
|
||||||
if options.quiet:
|
if options.quiet:
|
||||||
capture = cStringIO.StringIO()
|
capture = cStringIO.StringIO()
|
||||||
|
|||||||
@@ -24,4 +24,10 @@ if __name__ == '__main__':
|
|||||||
freeze_support()
|
freeze_support()
|
||||||
except:
|
except:
|
||||||
sys.stderr.write('Sorry, -K only supported for python 2.6-2.7\n')
|
sys.stderr.write('Sorry, -K only supported for python 2.6-2.7\n')
|
||||||
|
if os.environ.has_key("COVERAGE_PROCESS_START"):
|
||||||
|
try:
|
||||||
|
import coverage
|
||||||
|
coverage.process_startup()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
gluon.widget.start(cron=True)
|
gluon.widget.start(cron=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user