diff --git a/.coveragerc b/.coveragerc index ac2cbb9..f97e9b6 100644 --- a/.coveragerc +++ b/.coveragerc @@ -4,6 +4,7 @@ source_pkgs = incremental # List of directory names. source = tests branch = True +parallel = True [paths] source = diff --git a/tests/test_examples.py b/tests/test_examples.py index b5f694a..4004850 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -5,8 +5,24 @@ Tests for the packaging examples. """ -from twisted.trial.unittest import TestCase +import os from importlib import metadata +from subprocess import run + +from build import ProjectBuilder +from twisted.python.filepath import FilePath +from twisted.trial.unittest import TestCase + + +TEST_DIR = FilePath(os.path.abspath(os.path.dirname(__file__))) + + +def build_and_install(path): # type: (FilePath) -> None + builder = ProjectBuilder(path.path) + pkgfile = builder.build("wheel", output_directory=os.environ["PIP_FIND_LINKS"]) + + # Force reinstall in case tox reused the venv. + run(["pip", "install", "--force-reinstall", pkgfile], check=True) class ExampleTests(TestCase): @@ -14,6 +30,8 @@ def test_setuppy_version(self): """ example_setuppy has a version of 1.2.3. """ + build_and_install(TEST_DIR.child("example_setuppy")) + import example_setuppy self.assertEqual(example_setuppy.__version__.base(), "1.2.3") @@ -23,6 +41,8 @@ def test_setuptools_version(self): """ example_setuptools has a version of 2.3.4. """ + build_and_install(TEST_DIR.child("example_setuptools")) + import example_setuptools self.assertEqual(example_setuptools.__version__.base(), "2.3.4") diff --git a/tox.ini b/tox.ini index 2be0a0e..a392c6a 100644 --- a/tox.ini +++ b/tox.ini @@ -15,6 +15,7 @@ envlist = wheel = true wheel_build_env = build deps = + tests: build tests: coverage tests: coverage-p tests,mypy: twisted @@ -27,6 +28,8 @@ extras = setenv = ; Suppress pointless chatter in the output. PIP_DISABLE_PIP_VERSION_CHECK=yes + tests: PIP_FIND_LINKS={distdir} + tests: COVERAGE_PROCESS_START={toxinidir}/.coveragerc commands = python -V @@ -38,11 +41,9 @@ commands = tests: coverage --version tests: {envbindir}/trial --version tests: coverage erase - tests: coverage run -p {envbindir}/trial incremental - tests: coverage run -p -m pip install --use-pep517 --find-links {distdir} ./tests/example_setuppy - tests: coverage run -p -m pip -vvv install --use-pep517 --find-links {distdir} ./tests/example_setuptools - tests: coverage run -p {envbindir}/trial tests/test_examples.py - tests: coverage combine + tests: coverage run {envbindir}/trial incremental + tests: coverage run {envbindir}/trial tests/test_examples.py + tests: coverage combine . tests/example_setuppy tests/example_setuptools tests: coverage report tests: coverage html tests: coverage xml