Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI/coverage: Fix addopts, migrate away from pytest-cov #5649

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ repos:
- id: pytest
files: python3/
name: check that the Python3 test suite in passes
entry: env PYTHONDEVMODE=yes sh -c 'python3 -m pytest -vv &&
entry: env PYTHONDEVMODE=yes sh -c 'coverage run && coverage xml &&
coverage html && coverage report &&
diff-cover --ignore-whitespace --compare-branch=origin/feature/py3
--show-uncovered --html-report .git/coverage-diff.html
--fail-under 50 .git/coverage3.11.xml'
Expand Down
31 changes: 18 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ skip_covered = true

[tool.coverage.run]
# Default command line for "coverage run": Run pytest in non-verbose mode
command_line = "-m pytest -p no:logging -p no:warnings"
command_line = "-m pytest -v -ra"

# Default data file for "coverage run": Store coverage data in .git/.coverage
data_file = ".git/.coverage"
# Default context for "coverage run": Use the name of the test function
Expand All @@ -75,7 +76,7 @@ relative_files = true
# Default output when writing "coveragle xml" data. This needs to match what
# diff-cover and coverage upload to Codecov expect
[tool.coverage.xml]
output = ".git/coverage.xml"
output = ".git/coverage3.11.xml"


# Default output directory for writing "coverage html" data.
Expand Down Expand Up @@ -199,18 +200,22 @@ exclude = [
# -----------------------------------------------------------------------------
# Options to enable for pytest by default:
# -v show what happens
# -rA show summary after running tests
# --cov=python3 measure coverage of the python3 directory
# --cov-fail-under minimum coverage percentage
# --cov-report=term-missing show missing lines in the coverage report
# --cov-report=html:<filename> generate an HTML coverage report(for viewing)
# --cov-report=xml:<filename> generate an XML coverage report(for upload)
# -ra show short summary after running tests
# Other options should not be passed using addopts, as addopts forces those
# options to be used every time pytest is run, which is very restrictive.
# Instead, use `coverage run` to configure coverage options, and support
# running specific tests by passing them as arguments to pytest:
# For example:
# coverage run -m pytest python3/tests/test_xenapi.py
# Adding specific --cov options using addopts is not recommended as it would
# require to use the pytest-cov plugin, which would conflict with the use of
# `coverage run`. Instead, use `coverage` to configure coverage options.
# Specifying directories to test is better done using the testpaths option,
# as testpaths sets the default directories to search for tests, but does not
# force them to be run, so you can still run specific tests files by just
# passing them as arguments to pytest: pytest python3/tests/test_xenapi.py
# -----------------------------------------------------------------------------
addopts = """
-v -rA --cov=python3 --cov=scripts --cov-fail-under=50
--cov-report=html:.git/coverage --cov-report=term-missing
--cov-report=xml:.git/coverage3.11.xml
"""
addopts = "-v -ra"

# -----------------------------------------------------------------------------
# Other pytest config options:
Expand Down
Loading