Skip to content

Commit

Permalink
fixup! test: Enable coverage in integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealFalcon committed Jan 15, 2024
1 parent e414d0d commit d33dee0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
11 changes: 9 additions & 2 deletions tests/integration_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,17 @@ def _generate_coverage_report() -> None:
cwd=str(parent_dir),
stdout=subprocess.DEVNULL,
)
html_dir = parent_dir / "html"
html_dir.mkdir()
subprocess.run(
["coverage", "html", "--ignore-errors"],
[
"coverage",
"html",
f"--data-file={parent_dir / '.coverage'}",
f"--directory={html_dir}",
"--ignore-errors",
],
check=True,
cwd=str(parent_dir),
stdout=subprocess.DEVNULL,
)
log.info("Coverage report generated")
Expand Down
5 changes: 3 additions & 2 deletions tests/integration_tests/integration_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@

# We default our coverage to False because it involves modifying the
# cloud-init systemd services, which is too intrusive of a change to
# enable by default. If changed to true, the LOCAL_LOG_PATH defined
# above will contain an `html` directory with the coverage report.
# enable by default. If changed to true, the test directory corresponding
# to the test run under LOCAL_LOG_PATH defined above will contain an
# `html` directory with the coverage report.
INCLUDE_COVERAGE = False

##################################################################
Expand Down
1 change: 1 addition & 0 deletions tests/integration_tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from cloudinit.subp import subp

if TYPE_CHECKING:
# instances.py has imports util.py, so avoid circular import
from tests.integration_tests.instances import IntegrationInstance

log = logging.getLogger("integration_testing")
Expand Down
5 changes: 5 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -330,3 +330,8 @@ markers =
unstable: skip this test because it is flakey
user_data: the user data to be passed to the test instance
allow_dns_lookup: disable autochecking for host network configuration

[coverage:paths]
source =
cloudinit/
/usr/lib/python3/dist-packages/cloudinit/

0 comments on commit d33dee0

Please sign in to comment.