Skip to content

Commit

Permalink
refactor test and coverage config
Browse files Browse the repository at this point in the history
  • Loading branch information
kingarrrt committed Oct 14, 2023
1 parent c78d11c commit d2133e6
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 61 deletions.
2 changes: 1 addition & 1 deletion .skel
Submodule .skel updated from 8256e4 to f8bdda
13 changes: 6 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
include .skel/Makefile

utest ftest: export DISTINFO_RAISE_ON_HIT=0

$(eval $(call TEST,ptest,acceptance/test_packages.py))
$(eval $(call TEST,ptest,packages))

NUM_PROCESSES ?= logical

atest ptest: override ARGS += --numprocesses=$(NUM_PROCESSES)
.atest .ptest: override ARGS += --numprocesses=$(NUM_PROCESSES)

.utest .ftest: export DISTINFO_RAISE_ON_HIT=0

# default is 50, this seems to be enough
FLAKE_RUNS ?= 20
FLAKE_MAX_MINUTES ?= 5

atest: override ARGS += -x --flake-finder --flake-runs=$(FLAKE_RUNS)
atest: override ARGS += -x --flake-finder --flake-max-minutes=$(FLAKE_MAX_MINUTES)

.PHONY: push
push:
Expand Down
11 changes: 5 additions & 6 deletions covcfg-atest.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
[html]
title = "Acceptance Test Coverage Report"
[run]
omit = [
"tests/functional/*",
"tests/unit/*",
]

[report]
exclude_lines = [
"pragma: no ptest cover",
"pragma: no ftest ptest cover",
]
omit = [
"tests/functional/*",
"tests/unit/*",
]
15 changes: 7 additions & 8 deletions covcfg-ftest.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
[html]
title = "Functional Test Coverage Report"
[run]
omit = [
"distinfo/__main__.py",
"distinfo/cli.py",
"tests/acceptance/*",
"tests/unit/*",
]

[report]
# TODO: once things have stabilized - there are some code paths that may not be needed
# fail_under = 90
exclude_lines = [
"pragma: no ftest cover",
"pragma: no utest ftest cover",
"pragma: no ftest ptest cover",
]
omit = [
"tests/acceptance/*",
"tests/unit/*",
]
15 changes: 7 additions & 8 deletions covcfg-ptest.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
[html]
title = "Package Test Coverage Report"

[report]
exclude_lines = [
"pragma: no ptest cover",
"pragma: no ftest ptest cover",
]
[run]
omit = [
"distinfo/__main__.py",
"distinfo/cli.py",
Expand All @@ -14,3 +7,9 @@ omit = [
"tests/functional/*",
"tests/unit/*",
]

[report]
exclude_lines = [
"pragma: no ptest cover",
"pragma: no ftest ptest cover",
]
15 changes: 7 additions & 8 deletions covcfg-utest.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
[html]
title = "Unit Test Coverage Report"

[report]
exclude_lines = [
"pragma: no utest cover",
"pragma: no utest ftest cover",
]
[run]
omit = [
"distinfo/__main__.py",
"distinfo/cli.py",
Expand All @@ -15,3 +8,9 @@ omit = [
"tests/acceptance/*",
"tests/functional/*",
]

[report]
exclude_lines = [
"pragma: no utest cover",
"pragma: no utest ftest cover",
]
2 changes: 1 addition & 1 deletion distinfo/collector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from .cargo import Cargo
from .collector import Collector, CollectorMixin
from .distcollector import DistCollector
from .findpackages import FindPackages
from .findpkgs import FindPkgs
from .findtests import FindTests
from .metadata import (
DirtyCollector,
Expand Down
4 changes: 2 additions & 2 deletions distinfo/collector/distcollector.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from ..distribution import Distribution
from .cargo import Cargo
from .collector import Collector, CollectorMixin
from .findpackages import FindPackages
from .findpkgs import FindPkgs
from .findtests import FindTests
from .metadata import (
PathMetadata,
Expand Down Expand Up @@ -217,7 +217,7 @@ async def _collect_metadata(self) -> None:
tg.start_soon(self._collector, PathMetadata)
# run path packages collector if modules and packages not set
if not ("modules" in self.dist.ext or "packages" in self.dist.ext):
tg.start_soon(self._collector, FindPackages)
tg.start_soon(self._collector, FindPkgs)

@overload
async def _collector(self, cls: type[Collector]) -> bool:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


@dataclasses.dataclass(**DATACLASS_DEFAULTS)
class FindPackages(Collector):
class FindPkgs(Collector):
async def _collect(self) -> bool:
from setuptools import Distribution as SetuptoolsDistribution
from setuptools.discovery import ConfigDiscovery
Expand Down
29 changes: 14 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,19 @@ homepage = "https://github.com/0compute/distinfo"
[tool.black]
target-version = ["py310"]

[tool.coverage.html]
directory = ".htmlcov"
show_contexts = true

[tool.coverage.run]
branch = true
concurrency = ["thread"]
data_file = ".coverage"
parallel = true
source = [
"distinfo",
"tests",
".",
]

[tool.coverage.xml]
output = "coverage.xml"
omit = [
".skel/*",
"tests/sitecustomize.py",
"tests/whitelist.py",
]
relative_files = true

[tool.coverage.report]
exclude_lines = [
Expand All @@ -137,14 +134,16 @@ exclude_lines = [
"pass",
]
# fail_under = 100
omit = [
"tests/covcfg.py",
"tests/sitecustomize.py",
"tests/whitelist.py",
]
# don't skip covered because we want to see what contexts exercise a code path
# skip_covered = true

[tool.coverage.html]
directory = ".htmlcov"
show_contexts = true

[tool.coverage.xml]
output = "coverage.xml"

[tool.isort]
profile = "black"
combine_as_imports = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

from typing import TYPE_CHECKING

from distinfo.collector import FindPackages
from distinfo.collector import FindPkgs

from .cases import Case

if TYPE_CHECKING:
from py.path import local


class TestFindPackages(Case):
collector = FindPackages
class TestFindPkgs(Case):
collector = FindPkgs

async def test_collect_empty(self, tmpdir: local) -> None:
collector, _requires = await self._collect(tmpdir)
for key in ("modules", "packages"):
assert key not in collector.dist.ext

async def test_collect_packages(self, tmpdir: local) -> None:
async def test_collect_pkgs(self, tmpdir: local) -> None:
aaa = self._write_package(tmpdir, "aaa")
self._write_package(aaa, "bbb")
self._write_package(tmpdir, "ccc")
Expand Down

0 comments on commit d2133e6

Please sign in to comment.