Skip to content

Commit 9b2c22b

Browse files
committed
More fixes
1 parent 9a403dc commit 9b2c22b

1 file changed

Lines changed: 27 additions & 11 deletions

File tree

cuda_core/tests/example_tests/test_basic_examples.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import glob
77
import os
8+
import platform
89
import re
910
import subprocess
1011
import sys
@@ -18,8 +19,8 @@
1819
# 1) Directly running the example in the same environment as the test suite.
1920
# This gives access to the current development version of cuda_core.
2021
# 2) Running the example in a subprocess with "uv run" to verify that the PEP
21-
# 723 metadata installation works correctly and that the example can be run in
22-
# isolation from the test suite.
22+
# 723 metadata works correctly and that the example can be run in isolation from
23+
# the test suite.
2324

2425

2526
def has_compute_capability_9_or_higher() -> bool:
@@ -36,6 +37,14 @@ def has_display() -> bool:
3637
return False
3738

3839

40+
def is_not_windows() -> bool:
41+
return sys.platform != "win32"
42+
43+
44+
def is_x86_64() -> bool:
45+
return platform.machine() == "x86_64"
46+
47+
3948
def uv_installed() -> bool:
4049
try:
4150
subprocess.run(["uv", "--version"], check=True) # noqa: S607
@@ -45,10 +54,10 @@ def uv_installed() -> bool:
4554

4655

4756
PACKAGE_REQUIREMENTS = {
48-
"pytorch_example.py": ["torch"],
4957
"cuda_graphs.py": ["cupy"],
5058
"jit_lto_fractal.py": ["cupy"],
5159
"memory_ops.py": ["cupy"],
60+
"pytorch_example.py": ["torch"],
5261
"saxpy.py": ["cupy"],
5362
"simple_multi_gpu_example.py": ["cupy"],
5463
"strided_memory_view_cpu.py": ["cffi"],
@@ -60,8 +69,10 @@ def uv_installed() -> bool:
6069

6170
SYSTEM_REQUIREMENTS = {
6271
"gl_interop_plasma.py": has_display,
63-
"thread_block_cluster.py": has_compute_capability_9_or_higher,
72+
"pytorch_example.py": is_x86_64, # PyTorch only provides CUDA support for x86_64
6473
"simple_multi_gpu_example.py": has_multiple_devices,
74+
"strided_memory_view_cpu.py": is_not_windows,
75+
"thread_block_cluster.py": has_compute_capability_9_or_higher,
6576
}
6677

6778

@@ -86,11 +97,14 @@ def test_example(self, example):
8697
example_path = os.path.join(samples_path, example)
8798
process = subprocess.run([sys.executable, example_path], capture_output=True) # noqa: S603
8899
if process.returncode != 0:
89-
print(process.stdout.decode())
90-
print(process.stderr.decode(), file=sys.stderr)
91-
raise AssertionError(f"Example failed with return code {process.returncode} ({example})")
100+
if process.stdout:
101+
print(process.stdout.decode())
102+
if process.stderr:
103+
print(process.stderr.decode(), file=sys.stderr)
104+
raise AssertionError(f"`{example}` failed ({process.returncode})")
92105

93106
@pytest.mark.skipif(not uv_installed(), reason="uv is required to test PEP 723 metadata installation")
107+
@pytest.mark.skipif(sys.platform == "win32", reason="uv does not currently work on Windows in CI")
94108
def test_example_pep723(self, example):
95109
system_requirement = SYSTEM_REQUIREMENTS.get(example, lambda: True)
96110
if not system_requirement():
@@ -101,9 +115,11 @@ def test_example_pep723(self, example):
101115
if process.returncode != 0:
102116
# This example requires a development version of cuda_core, so requirements can't be met.
103117
# That's ok, it was tested in the other test, so we just skip it instead of failing.
104-
if re.match(process.stderr.decode(), "Because only cuda-(core|bindings)"):
118+
if re.search("Because only cuda-(core)|(bindings)", process.stderr.decode()):
105119
pytest.skip(f"Skipping {example} due to unmet PEP 723 requirement")
106120

107-
print(process.stdout.decode())
108-
print(process.stderr.decode(), file=sys.stderr)
109-
raise AssertionError(f"Example failed with return code {process.returncode} ({example})")
121+
if process.stdout:
122+
print(process.stdout.decode())
123+
if process.stderr:
124+
print(process.stderr.decode(), file=sys.stderr)
125+
raise AssertionError(f"`uv run {example}` failed ({process.returncode})")

0 commit comments

Comments
 (0)