test(core): stop four cuda_core tests from reporting failures as skips - #2577
Open
LeSingh1 wants to merge 1 commit into
Open
test(core): stop four cuda_core tests from reporting failures as skips#2577LeSingh1 wants to merge 1 commit into
LeSingh1 wants to merge 1 commit into
Conversation
Two shapes, both of which make a real regression invisible. 1. test_graphics.py -- `yield` inside `except Exception: pytest.skip(...)`. `_gl_context_and_buffer` and `_gl_context_and_texture` wrap creation AND the yield in one try. @contextmanager re-throws the with-body's exception at the yield, so any failure inside a test -- a failed assertion, a CUDAError out of GraphicsResource -- lands in that handler and is reported as "Could not create GL context/buffer: AssertionError: ...". Every test using these two helpers can only pass or skip. Split creation into helpers and keep the yield outside the handler, so only a genuine environment failure skips. Same fix as NVIDIA#2565 applied to the cuda.bindings twin (test_graphics_apis.py::_gl_context). 2. test_device.py -- `except (ValueError, Exception)` around the assertions. AssertionError is an Exception, so test_device_inequality_different_id and test_device_inequality_different_id_hash reported a genuine failure (two distinct devices comparing equal, or hashing equal) as "Test requires at least 2 CUDA devices". Decide up front with `system.get_num_devices() < 2`, the idiom already used by test_stream, test_green_context, test_object_protocols and test_tensor_map, and leave the assertions unguarded. Also drops a duplicated `assert dev0 != dev1` that differed only in its message.
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Four
cuda_coretests can currently only pass or skip — a genuine regression is reported as a skipped test. Two different shapes, grouped because they are the same defect and the same fix story.1.
test_graphics.py:yieldinsideexcept Exception: pytest.skip(...)_gl_context_and_bufferand_gl_context_and_texturewrap both the GL setup and theyieldin onetry:@contextmanagerre-throws thewith-body's exception at the yield, so anything a test raises — a failed assertion, aCUDAErrorout ofGraphicsResource— lands in that handler and is reported asCould not create GL context/buffer: AssertionError: .... Every test that uses these two helpers is unfailable.Fixed by splitting creation into
_make_gl_context/_create_gl_buffer/_create_gl_textureand keeping theyieldoutside the handler, so only a genuine environment failure skips. This is the same fix #2565 makes for thecuda.bindingstwin (test_graphics_apis.py::_gl_context); the two files are independent, so this is a separate change rather than a rebase of that one.2.
test_device.py:except (ValueError, Exception)around the assertionsAssertionErroris anException, so on a machine with two GPUs a real failure — two distinct devices comparing equal, or hashing equal — is reported asTest requires at least 2 CUDA devices. ((ValueError, Exception)is also redundant:ValueErroris already covered.)Fixed by deciding up front with
system.get_num_devices() < 2— the idiom already used bytest_stream.py:413,test_green_context.py:296,test_object_protocols.py:173andtest_tensor_map.py:389— and leaving the assertions unguarded. Also drops a duplicatedassert dev0 != dev1that differed only in its message.What I ran
Environment: macOS, no CUDA driver and no CUDA toolkit, so
cuda.corecannot be built or imported here.test_graphics.pyneeds a GPU and a GL context,test_device.pyneeds two GPUs.python -m py_compile,ruff check,ruff format --checkon both changed files — clean, no new findings against amainbaseline.pytest.skipraisesSkipped, which derives fromBaseException, so thepytest.importorskip("pyglet")and the no-DISPLAY skip inside the extracted_make_gl_contextstill propagate through the newexcept Exceptionhandler rather than being converted into a "could not create" message.from cuda.core import systemis the same import the four sibling test modules use;cuda.core.systemis already imported bycuda/core/__init__.py.Refs #2565