2020-02-03 23:05:45 +01:00
|
|
|
#!/usr/bin/env python3
|
2017-07-24 22:38:48 +01:00
|
|
|
|
2022-07-14 13:36:57 +02:00
|
|
|
|
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
|
2017-03-20 23:54:29 +00:00
|
|
|
|
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()
|
|
|
|
|
|
2017-09-06 15:07:58 +02:00
|
|
|
# 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
|
|
|
|
2024-09-12 21:32:43 +02:00
|
|
|
if sys.platform.startswith("linux") and os.environ.get("CIBW_PLATFORM", "linux") == "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",
|
2025-03-12 04:48:35 +08:00
|
|
|
"--dist",
|
|
|
|
|
"loadgroup",
|
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",
|
2025-03-12 04:48:35 +08:00
|
|
|
"-vv",
|
2022-06-27 19:08:46 +01:00
|
|
|
]
|
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)
|