-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_coverage_nogpu.py
More file actions
executable file
·115 lines (98 loc) · 3.39 KB
/
run_coverage_nogpu.py
File metadata and controls
executable file
·115 lines (98 loc) · 3.39 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/env -S uv run --script
"""
Run coverage tests without GPU dependencies.
This script separates CPU-only tests from GPU/Qt-dependent tests.
"""
import subprocess
import sys
def run_command(cmd: str, description: str) -> bool:
"""Run a command and return success status."""
print(f"\n{'=' * 60}")
print(f"Running: {description}")
print(f"Command: {cmd}")
print(f"{'=' * 60}")
try:
result = subprocess.run(
cmd, shell=True, check=True, capture_output=True, text=True
)
print(result.stdout)
if result.stderr:
print("STDERR:", result.stderr)
return True
except subprocess.CalledProcessError as e:
print(f"Error: {e}")
print("STDOUT:", e.stdout)
print("STDERR:", e.stderr)
return False
def main():
"""Main function to run coverage without GPU."""
# CPU-only tests (no OpenGL context, no Qt)
cpu_only_tests = [
"tests/test_vec2.py",
"tests/test_vec3.py",
"tests/test_vec4.py",
"tests/test_vec2_array.py",
"tests/test_vec3_array.py",
"tests/test_vec4_array.py",
"tests/test_mat2.py",
"tests/test_mat3.py",
"tests/test_mat4.py",
"tests/test_quaternion.py",
"tests/test_transform.py",
"tests/test_bbox.py",
"tests/test_plane.py",
"tests/test_bezier_curve.py",
"tests/test_util.py",
"tests/test_random.py",
"tests/test_logging.py",
"tests/test_first_person_camera.py",
"tests/test_pyside_event_handling_mixin.py",
"tests/test_image.py",
"tests/test_webgpu_constants.py",
"tests/test_webgpu_pipelines.py",
]
# GPU-dependent tests (require OpenGL context)
gpu_tests = [
"tests/test_shaderlib.py",
"tests/test_vao.py",
"tests/test_texture.py",
"tests/test_text.py",
"tests/test_base_mesh.py",
"tests/test_primitives.py",
"tests/test_obj.py",
]
# Qt widget tests (require pytest-qt)
qt_tests = [
"tests/test_vec2_widget.py",
"tests/test_vec3_widget.py",
"tests/test_vec4_widget.py",
"tests/test_rgb_colour_widget.py",
"tests/test_rgba_colour_widget.py",
"tests/test_lookat_widget.py",
"tests/test_transform_widget.py",
"tests/test_webgpu_widget.py",
]
print("PyNGL Coverage without GPU")
print("=" * 60)
print(f"CPU-only tests: {len(cpu_only_tests)}")
print(f"GPU tests: {len(gpu_tests)} (skipped)")
print(f"Qt tests: {len(qt_tests)} (skipped)")
# Build test file list
test_files = " ".join(cpu_only_tests)
# Run coverage
coverage_cmd = f'uv run coverage run --source=src/ncca/ngl --omit="*/tests/*,*/test_*/__main__.py" -m pytest -p no:pytest-qt {test_files} -v'
success = run_command(coverage_cmd, "Coverage for CPU-only tests")
if success:
# Generate reports
run_command("uv run coverage report -m", "Coverage report")
run_command("uv run coverage xml", "Coverage XML for SonarCloud")
run_command("uv run coverage html", "Coverage HTML report")
print(f"\n{'=' * 60}")
print("Coverage completed successfully!")
print("HTML report available at: htmlcov/index.html")
print(f"{'=' * 60}")
else:
print("\nCoverage failed!")
sys.exit(1)
if __name__ == "__main__":
main()