Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions cuda_core/tests/graph/test_graph_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,10 @@ def noop(data):
pass

node = g.callback(noop)
return node, {}
return node, {
# A ctypes function pointer callback has no Python callable.
"callback": lambda v: v is None,
}


def _build_child_graph_node(g):
Expand Down Expand Up @@ -550,16 +553,25 @@ def _build_switch_node(g):
]


@pytest.fixture(params=_NODE_SPECS)
def node_spec(request, init_cuda):
spec = request.param
def _build_node_spec(spec):
if spec.needs_mempool:
skip_if_mempool_unsupported()
g = GraphDefinition()
node, expected_attrs = spec.builder(g)
return spec, g, node, expected_attrs


@pytest.fixture(params=_NODE_SPECS)
def node_spec(request, init_cuda):
return _build_node_spec(request.param)


@pytest.fixture(params=[param for param in _NODE_SPECS if param.id != "empty"])
def node_spec_with_attrs(request, init_cuda):
"""Like ``node_spec``, without the empty node, which has no type-specific attributes."""
return _build_node_spec(request.param)


# =============================================================================
# Fixtures
# =============================================================================
Expand Down Expand Up @@ -689,13 +701,10 @@ def test_node_type_preserved_by_pred_succ(node_spec):
assert matched[0] is node


# For node_spec values empty and host_callback_cfunc:
# This test is not currently run in any CI job
def test_node_attrs(node_spec):
def test_node_attrs(node_spec_with_attrs):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Heavy lift

Add an automated check for the host_callback_cfunc cases.

Issue #3570 requires a way to confirm automatically that both [host_callback_cfunc] attribute cases run in at least one CI configuration. This PR removes the "not run in CI" markers but adds no such check. The core job runs pytest ... tests/ without a selection filter (ci/tools/run-tests:190), so the cases run today. Nothing in the change, however, fails CI if either case is later deselected or skipped. The requirement stays unmet until a CI-side check exists.

Add a CI check that fails the run when either host_callback_cfunc case is missing from the results or is skipped. The check's form is open. Options include inspecting the JUnit output the core job already writes, or a test-level assertion on collection. Choose one and document the choice.

"""Type-specific attributes have expected values after construction."""
spec, g, node, expected_attrs = node_spec
if not expected_attrs:
pytest.skip("no type-specific attributes")
spec, g, node, expected_attrs = node_spec_with_attrs
assert expected_attrs, f"{spec.name}: no expected attributes"
for attr, expected in expected_attrs.items():
actual = getattr(node, attr)
if callable(expected):
Expand All @@ -704,13 +713,10 @@ def test_node_attrs(node_spec):
assert actual == expected, f"{spec.name}.{attr}: expected {expected}, got {actual}"


# For node_spec values empty and host_callback_cfunc:
# This test is not currently run in any CI job
def test_node_attrs_preserved_by_nodes(node_spec):
def test_node_attrs_preserved_by_nodes(node_spec_with_attrs):
"""Type-specific attributes survive round-trip through graph_definition.nodes()."""
spec, g, node, expected_attrs = node_spec
if not expected_attrs:
pytest.skip("no type-specific attributes")
spec, g, node, expected_attrs = node_spec_with_attrs
assert expected_attrs, f"{spec.name}: no expected attributes"
if spec.roundtrip_class != spec.expected_class:
pytest.skip("reconstructed type differs — attrs not preserved")
retrieved = next(n for n in g.nodes() if n == node)
Expand Down
Loading