forked from pypa/cibuildwheel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_tests.py
executable file
·90 lines (77 loc) · 2.33 KB
/
run_tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env python3
import argparse
import os
import subprocess
import sys
from pathlib import Path
if __name__ == "__main__":
if sys.version_info < (3, 13):
default_cpu_count = os.cpu_count() or 2
else:
default_cpu_count = os.process_cpu_count() or 2
parser = argparse.ArgumentParser()
parser.add_argument(
"--run-podman", action="store_true", default=False, help="run podman tests (linux only)"
)
parser.add_argument(
"--num-processes",
action="store",
default=default_cpu_count,
help="number of processes to use for testing",
)
args = parser.parse_args()
# move cwd to the project root
os.chdir(Path(__file__).resolve().parents[1])
# unit tests
unit_test_args = [sys.executable, "-m", "pytest", "unit_test"]
if sys.platform.startswith("linux") and os.environ.get("CIBW_PLATFORM", "linux") == "linux":
# run the docker unit tests only on Linux
unit_test_args += ["--run-docker"]
if args.run_podman:
unit_test_args += ["--run-podman"]
print(
"\n\n================================== UNIT TESTS ==================================",
flush=True,
)
subprocess.run(unit_test_args, check=True)
# Run the serial integration tests without multiple processes
serial_integration_test_args = [
sys.executable,
"-m",
"pytest",
"-m",
"serial",
"-x",
"--durations",
"0",
"--timeout=2400",
"test",
"-vv",
]
print(
"\n\n=========================== SERIAL INTEGRATION TESTS ===========================",
flush=True,
)
subprocess.run(serial_integration_test_args, check=True)
# Non-serial integration tests
integration_test_args = [
sys.executable,
"-m",
"pytest",
"-m",
"not serial",
f"--numprocesses={args.num_processes}",
"-x",
"--durations",
"0",
"--timeout=2400",
"test",
"-vv",
]
if sys.platform.startswith("linux") and args.run_podman:
integration_test_args += ["--run-podman"]
print(
"\n\n========================= NON-SERIAL INTEGRATION TESTS =========================",
flush=True,
)
subprocess.run(integration_test_args, check=True)