Files
cibuildwheel/bin/run_tests.py
T

57 lines
1.4 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
from __future__ import annotations
2022-06-27 19:08:46 +01:00
import argparse
2019-11-12 23:51:27 +00:00
import os
import subprocess
import sys
2020-06-18 02:00:30 +02:00
from pathlib import Path
2021-05-03 11:45:43 -04:00
if __name__ == "__main__":
2024-02-29 22:27:09 +01:00
default_cpu_count = os.cpu_count() or 2
2022-06-27 19:08:46 +01:00
parser = argparse.ArgumentParser()
2022-06-29 20:18:08 +01:00
parser.add_argument(
"--run-podman", action="store_true", default=False, help="run podman tests (linux only)"
)
2024-02-29 22:27:09 +01:00
parser.add_argument(
"--num-processes",
action="store",
default=default_cpu_count,
help="number of processes to use for testing",
)
2022-06-27 19:08:46 +01:00
args = parser.parse_args()
# move cwd to the project root
2020-06-18 02:00:30 +02:00
os.chdir(Path(__file__).resolve().parents[1])
2017-09-01 13:32:34 +01:00
2022-06-27 19:08:46 +01:00
# unit tests
2021-05-03 11:45:43 -04:00
unit_test_args = [sys.executable, "-m", "pytest", "unit_test"]
2022-06-27 19:08:46 +01:00
2021-05-03 11:45:43 -04:00
if sys.platform.startswith("linux"):
2022-06-27 19:08:46 +01:00
# run the docker unit tests only on Linux
2021-05-03 11:45:43 -04:00
unit_test_args += ["--run-docker"]
2022-06-29 20:18:08 +01:00
if args.run_podman:
unit_test_args += ["--run-podman"]
2022-06-27 19:08:46 +01:00
2021-02-14 12:56:33 -05:00
subprocess.run(unit_test_args, check=True)
2017-09-01 13:32:34 +01:00
2022-06-27 19:08:46 +01:00
# integration tests
integration_test_args = [
sys.executable,
"-m",
"pytest",
2024-02-29 22:27:09 +01:00
f"--numprocesses={args.num_processes}",
2022-06-27 19:08:46 +01:00
"-x",
"--durations",
"0",
"--timeout=2400",
"test",
]
2022-06-29 20:18:08 +01:00
if sys.platform.startswith("linux") and args.run_podman:
2022-06-27 19:08:46 +01:00
integration_test_args += ["--run-podman"]
subprocess.run(integration_test_args, check=True)