Add an integration test for a podman build
This commit is contained in:
@@ -75,7 +75,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Test cibuildwheel
|
- name: Test cibuildwheel
|
||||||
run: |
|
run: |
|
||||||
python ./bin/run_tests.py
|
python ./bin/run_tests.py --run-podman
|
||||||
|
|
||||||
test-emulated:
|
test-emulated:
|
||||||
name: Test emulated cibuildwheel using qemu
|
name: Test emulated cibuildwheel using qemu
|
||||||
|
|||||||
+27
-17
@@ -1,33 +1,43 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import argparse
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("--run-podman", action="store_true", default=False, help="run podman tests")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
# move cwd to the project root
|
# move cwd to the project root
|
||||||
os.chdir(Path(__file__).resolve().parents[1])
|
os.chdir(Path(__file__).resolve().parents[1])
|
||||||
|
|
||||||
# run the unit tests
|
# unit tests
|
||||||
unit_test_args = [sys.executable, "-m", "pytest", "unit_test"]
|
unit_test_args = [sys.executable, "-m", "pytest", "unit_test"]
|
||||||
# run the docker unit tests only on Linux
|
|
||||||
if sys.platform.startswith("linux"):
|
if sys.platform.startswith("linux"):
|
||||||
|
# run the docker unit tests only on Linux
|
||||||
unit_test_args += ["--run-docker"]
|
unit_test_args += ["--run-docker"]
|
||||||
|
if args.run_podman:
|
||||||
|
unit_test_args += ["--run-podman"]
|
||||||
|
|
||||||
subprocess.run(unit_test_args, check=True)
|
subprocess.run(unit_test_args, check=True)
|
||||||
|
|
||||||
# run the integration tests
|
# integration tests
|
||||||
subprocess.run(
|
integration_test_args = [
|
||||||
[
|
sys.executable,
|
||||||
sys.executable,
|
"-m",
|
||||||
"-m",
|
"pytest",
|
||||||
"pytest",
|
"--numprocesses=2",
|
||||||
"--numprocesses=2",
|
"-x",
|
||||||
"-x",
|
"--durations",
|
||||||
"--durations",
|
"0",
|
||||||
"0",
|
"--timeout=2400",
|
||||||
"--timeout=2400",
|
"test",
|
||||||
"test",
|
]
|
||||||
],
|
if args.run_podman:
|
||||||
check=True,
|
integration_test_args += ["--run-podman"]
|
||||||
)
|
|
||||||
|
subprocess.run(integration_test_args, check=True)
|
||||||
|
|||||||
+1
-14
@@ -7,20 +7,7 @@ def pytest_addoption(parser) -> None:
|
|||||||
parser.addoption(
|
parser.addoption(
|
||||||
"--run-emulation", action="store_true", default=False, help="run emulation tests"
|
"--run-emulation", action="store_true", default=False, help="run emulation tests"
|
||||||
)
|
)
|
||||||
|
parser.addoption("--run-podman", action="store_true", default=False, help="run podman tests")
|
||||||
|
|
||||||
def pytest_configure(config):
|
|
||||||
config.addinivalue_line("markers", "emulation: mark test requiring qemu binfmt_misc to run")
|
|
||||||
|
|
||||||
|
|
||||||
def pytest_collection_modifyitems(config, items) -> None:
|
|
||||||
if config.getoption("--run-emulation"):
|
|
||||||
# --run-emulation given in cli: do not skip emulation tests
|
|
||||||
return
|
|
||||||
skip_emulation = pytest.mark.skip(reason="need --run-emulation option to run")
|
|
||||||
for item in items:
|
|
||||||
if "emulation" in item.keywords:
|
|
||||||
item.add_marker(skip_emulation)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(
|
@pytest.fixture(
|
||||||
|
|||||||
@@ -17,8 +17,10 @@ def test_spam():
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.emulation
|
def test(tmp_path, request):
|
||||||
def test(tmp_path):
|
if not request.config.getoption("--run-emulation"):
|
||||||
|
pytest.skip("needs --run-emulation option to run")
|
||||||
|
|
||||||
project_dir = tmp_path / "project"
|
project_dir = tmp_path / "project"
|
||||||
project_with_a_test.generate(project_dir)
|
project_with_a_test.generate(project_dir)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import pytest
|
||||||
|
|
||||||
|
from . import test_projects, utils
|
||||||
|
|
||||||
|
basic_project = test_projects.new_c_project()
|
||||||
|
|
||||||
|
|
||||||
|
def test(tmp_path, capfd, request):
|
||||||
|
if utils.platform != "linux":
|
||||||
|
pytest.skip("the test is only relevant to the linux build")
|
||||||
|
|
||||||
|
if not request.config.getoption("--run-podman"):
|
||||||
|
pytest.skip("needs --run-podman option to run")
|
||||||
|
|
||||||
|
project_dir = tmp_path / "project"
|
||||||
|
basic_project.generate(project_dir)
|
||||||
|
|
||||||
|
# build some musllinux and manylinux wheels (ensuring that we use two containers)
|
||||||
|
actual_wheels = utils.cibuildwheel_run(
|
||||||
|
project_dir,
|
||||||
|
add_env={
|
||||||
|
"CIBW_BUILD": "cp310-*{manylinux,musllinux}_x86_64",
|
||||||
|
"CIBW_BEFORE_ALL": "echo 'test log statement from before-all'",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
# check that the expected wheels are produced
|
||||||
|
expected_wheels = [
|
||||||
|
w
|
||||||
|
for w in utils.expected_wheels("spam", "0.1.0")
|
||||||
|
if ("-cp310-" in w) and ("x86_64" in w) and ("manylinux" in w or "musllinux" in w)
|
||||||
|
]
|
||||||
|
assert set(actual_wheels) == set(expected_wheels)
|
||||||
|
|
||||||
|
# check that stdout is bring passed-though from container correctly
|
||||||
|
captured = capfd.readouterr()
|
||||||
|
assert "test log statement from before-all" in captured.out
|
||||||
Reference in New Issue
Block a user