mirror of
https://github.com/valitydev/salt.git
synced 2024-11-06 16:45:27 +00:00
Merge pull request #5371 from s0undt3ch/develop
Improve coveralls coverage data feeding
This commit is contained in:
commit
874194faa9
@ -1,2 +0,0 @@
|
||||
[run]
|
||||
branch = True
|
@ -15,10 +15,10 @@ before_install:
|
||||
|
||||
install: pip install -r requirements.txt --use-mirrors --mirrors=http://testpypi.python.org/pypi
|
||||
|
||||
script: "sudo -E /home/travis/virtualenv/python${TRAVIS_PYTHON_VERSION}/bin/coverage run setup.py test --runtests-opts='--run-destructive --sysinfo -v'"
|
||||
script: "sudo -E /home/travis/virtualenv/python${TRAVIS_PYTHON_VERSION}/bin/python setup.py test --runtests-opts='--run-destructive --sysinfo -v --coverage --no-coverage-report'"
|
||||
|
||||
after_script:
|
||||
- coveralls
|
||||
- coveralls --verbose
|
||||
|
||||
notifications:
|
||||
irc:
|
||||
|
@ -99,11 +99,16 @@ def __get_version(version, version_info):
|
||||
return version, version_info
|
||||
elif parsed_version_info < version_info:
|
||||
warnings.warn(
|
||||
'The parsed version info, `{0}`, is lower than the one '
|
||||
'defined in the file, `{1}`.'
|
||||
'In order to get the proper salt version with the git hash '
|
||||
'you need to update salt\'s local git tags. Something like: '
|
||||
'\'git fetch --tags\' or \'git fetch --tags upstream\' if '
|
||||
'you followed salt\'s contribute documentation. The version '
|
||||
'string WILL NOT include the git hash.',
|
||||
'string WILL NOT include the git hash.'.format(
|
||||
parsed_version_info,
|
||||
version_info
|
||||
),
|
||||
UserWarning,
|
||||
stacklevel=2
|
||||
)
|
||||
|
@ -22,11 +22,19 @@ except ImportError:
|
||||
xmlrunner = None
|
||||
|
||||
TEST_DIR = os.path.dirname(os.path.normpath(os.path.abspath(__file__)))
|
||||
SALT_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||
XML_OUTPUT_DIR = os.environ.get(
|
||||
'SALT_XML_TEST_REPORTS_DIR',
|
||||
os.path.join(TMP, 'xml-test-reports')
|
||||
)
|
||||
|
||||
|
||||
try:
|
||||
if SALT_ROOT:
|
||||
os.chdir(SALT_ROOT)
|
||||
except OSError, err:
|
||||
print 'Failed to change directory to salt\'s source: {0}'.format(err)
|
||||
|
||||
try:
|
||||
import coverage
|
||||
# Cover any subprocess
|
||||
@ -34,7 +42,7 @@ try:
|
||||
# Setup coverage
|
||||
code_coverage = coverage.coverage(
|
||||
branch=True,
|
||||
source=[os.path.join(os.path.dirname(TEST_DIR), 'salt')],
|
||||
source=[os.path.join(os.getcwd(), 'salt')],
|
||||
)
|
||||
except ImportError:
|
||||
code_coverage = None
|
||||
@ -280,6 +288,12 @@ def parse_opts():
|
||||
action='store_true',
|
||||
help='Run tests and report code coverage'
|
||||
)
|
||||
output_options_group.add_option(
|
||||
'--no-coverage-report',
|
||||
default=False,
|
||||
action='store_true',
|
||||
help='Don\'t build the coverage HTML report'
|
||||
)
|
||||
output_options_group.add_option(
|
||||
'--no-colors',
|
||||
'--no-colours',
|
||||
@ -461,19 +475,20 @@ if __name__ == '__main__':
|
||||
print('Current Directory: {0}'.format(os.getcwd()))
|
||||
print('Coverage data file exists? {0}'.format(os.path.isfile('.coverage')))
|
||||
|
||||
report_dir = os.path.join(os.path.dirname(__file__), 'coverage-report')
|
||||
print(
|
||||
'\nGenerating Coverage HTML Report Under {0!r} ...'.format(
|
||||
report_dir
|
||||
)
|
||||
),
|
||||
sys.stdout.flush()
|
||||
if opts.no_coverage_report is False:
|
||||
report_dir = os.path.join(os.path.dirname(__file__), 'coverage-report')
|
||||
print(
|
||||
'\nGenerating Coverage HTML Report Under {0!r} ...'.format(
|
||||
report_dir
|
||||
)
|
||||
),
|
||||
sys.stdout.flush()
|
||||
|
||||
if os.path.isdir(report_dir):
|
||||
import shutil
|
||||
shutil.rmtree(report_dir)
|
||||
code_coverage.html_report(directory=report_dir)
|
||||
print('Done.\n')
|
||||
if os.path.isdir(report_dir):
|
||||
import shutil
|
||||
shutil.rmtree(report_dir)
|
||||
code_coverage.html_report(directory=report_dir)
|
||||
print('Done.\n')
|
||||
|
||||
if false_count > 0:
|
||||
sys.exit(1)
|
||||
|
Loading…
Reference in New Issue
Block a user