Permalink
Browse files

Add coverage support

Use codecov for coverage reports. Add badge to README.
  • Loading branch information...
1 parent 768aea4 commit 9d6a17b140dda02e2aed16503ff4d024e1a822b6 @micbou micbou committed Oct 12, 2016
Showing with 253 additions and 203 deletions.
  1. +3 −0 .coveragerc
  2. +2 −0 .gitignore
  3. +3 −0 .travis.yml
  4. +1 −0 README.md
  5. +2 −0 appveyor.yml
  6. +18 −0 codecov.yml
  7. +192 −190 doc/youcompleteme.txt
  8. +4 −2 python/test_requirements.txt
  9. +28 −11 run_tests.py
View
@@ -0,0 +1,3 @@
+[report]
+omit =
+ */tests/*
View
@@ -28,8 +28,10 @@ pip-log.txt
# Unit test / coverage reports
.coverage
+python/cover/
.tox
nosetests.xml
+.noseids
#Translations
*.mo
View
@@ -10,10 +10,13 @@ install:
- source ci/travis/travis_install.sh
script:
- ci/travis/travis_script.sh
+after_success:
+ - codecov
env:
global:
# Travis can run out of RAM, so we need to be careful here.
- YCM_CORES=3
+ - COVERAGE=true
matrix:
- YCM_PYTHON_VERSION=2.7 YCM_FLAKE8=true
# Since 3.0.4, Flake8 is not working anymore on Python 2.6.
View
@@ -3,6 +3,7 @@ YouCompleteMe: a code-completion engine for Vim
[![Build Status](https://travis-ci.org/Valloric/YouCompleteMe.svg?branch=master)](https://travis-ci.org/Valloric/YouCompleteMe)
[![Build status](https://ci.appveyor.com/api/projects/status/ag9uqwi8s6btwjd8/branch/master?svg=true)](https://ci.appveyor.com/project/Valloric/YouCompleteMe)
+[![Coverage Status](https://codecov.io/gh/Valloric/YouCompleteMe/branch/master/graph/badge.svg)](https://codecov.io/gh/Valloric/YouCompleteMe)
- [Intro](#intro)
- [Installation](#installation)
View
@@ -12,6 +12,8 @@ install:
- ci\appveyor\appveyor_install.bat
build_script:
- python run_tests.py
+after_build:
+ - codecov
# Disable automatic tests
test: off
cache:
View
@@ -0,0 +1,18 @@
+codecov:
+ notify:
+ require_ci_to_pass: yes
+
+coverage:
+ precision: 2
+ round: down
+ range: 70...100
+
+ status:
+ # Learn more at https://codecov.io/docs#yaml_default_commit_status
+ project: true
+ patch: true
+ changes: true
+
+comment:
+ layout: "header, diff, changes, uncovered"
+ behavior: default # update if exists else create new
View
Oops, something went wrong.
@@ -1,6 +1,8 @@
flake8>=2.0
mock>=1.0.1
-nose>=1.3.0
+nose>=1.3.7
PyHamcrest>=1.8.0
-# This needs to be kept in sync with submodule checkout in third_party/ycmd/third_party
+# This needs to be kept in sync with submodule checkout in
+# third_party/ycmd/third_party
future==0.15.2
+codecov>=2.0.5
View
@@ -46,11 +46,18 @@ def RunFlake8():
def ParseArguments():
parser = argparse.ArgumentParser()
parser.add_argument( '--skip-build', action = 'store_true',
- help = 'Do not build ycmd before testing.' )
+ help = 'Do not build ycmd before testing' )
+ parser.add_argument( '--coverage', action = 'store_true',
+ help = 'Enable coverage report' )
parser.add_argument( '--no-flake8', action = 'store_true',
help = 'Do not run flake8' )
- return parser.parse_known_args()
+ parsed_args, nosetests_args = parser.parse_known_args()
+
+ if 'COVERAGE' in os.environ:
+ parsed_args.coverage = ( os.environ[ 'COVERAGE' ] == 'true' )
+
+ return parsed_args, nosetests_args
def BuildYcmdLibs( args ):
@@ -61,21 +68,31 @@ def BuildYcmdLibs( args ):
] )
-def NoseTests( extra_args ):
- subprocess.check_call( [
- 'nosetests',
- '-v',
- '-w',
- p.join( DIR_OF_THIS_SCRIPT, 'python' )
- ] + extra_args )
+def NoseTests( parsed_args, extra_nosetests_args ):
+ # Always passing --with-id to nosetests enables non-surprising usage of
+ # its --failed flag.
+ nosetests_args = [ '-v', '--with-id' ]
+
+ if parsed_args.coverage:
+ nosetests_args += [ '--with-coverage',
+ '--cover-erase',
+ '--cover-package=ycm',
+ '--cover-html' ]
+
+ if extra_nosetests_args:
+ nosetests_args.extend( extra_nosetests_args )
+ else:
+ nosetests_args.append( p.join( DIR_OF_THIS_SCRIPT, 'python' ) )
+
+ subprocess.check_call( [ 'nosetests' ] + nosetests_args )
def Main():
- ( parsed_args, extra_args ) = ParseArguments()
+ ( parsed_args, nosetests_args ) = ParseArguments()
if not parsed_args.no_flake8:
RunFlake8()
BuildYcmdLibs( parsed_args )
- NoseTests( extra_args )
+ NoseTests( parsed_args, nosetests_args )
if __name__ == "__main__":
Main()

0 comments on commit 9d6a17b

Please sign in to comment.