fix: Replace runtime_static_assert tests with compile tests.#9211
fix: Replace runtime_static_assert tests with compile tests.#9211arnavnagzirkar wants to merge 3 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe CMake test configuration updates test host/device backend restrictions: removing the restriction for ChangesTest Restriction Configuration
Assessment against linked issues
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 32744daa-0542-42e4-94bb-05a81cc89143
📒 Files selected for processing (3)
thrust/testing/CMakeLists.txtthrust/testing/fill_const_iterators_fail.cuthrust/testing/generate_const_iterators_fail.cu
bernhardmgruber
left a comment
There was a problem hiding this comment.
Hi! Thanks for to working on this. The stale thrust_declare_test_restrictions(unittest_static_assert CPP.CPP CPP.CUDA) is indeed a good catch and should be removed. I think the other two tests are not necessary, since we don't need to verify that we cannot write to a const iterator. As you wrote in the PR description, this is enforced by C++ already.
I suggest we reduce the PR to just the removal of the stale lines below:
| # This test is incompatible with TBB and OMP, since it requires special per-device | ||
| # handling to process exceptions in a device function, which is only implemented | ||
| # for CUDA. | ||
| thrust_declare_test_restrictions(unittest_static_assert CPP.CPP CPP.CUDA) | ||
|
|
The unittest_static_assert test no longer exists, so the restriction declaration was dead code. Per maintainer review, reduce the change to just removing these stale lines.
|
/ok to test ffd77f9 |
This comment has been minimized.
This comment has been minimized.
|
/ok to test 5dacdf1 |
😬 CI Workflow Results🟥 Finished in 34m 46s: Pass: 85%/70 | Total: 8h 59m | Max: 34m 42s | Hits: 99%/130915See results here. |
Summary
Root Cause
Issue #807 identified that some Thrust unit tests (e.g.,
generate_const_iterators.cu) used a problematic technique of redefiningTHRUST_STATIC_ASSERTat runtime to test that static assertions fire. This was done viathrust/testing/unittest/runtime_static_assert.h, which redefined the macro to throw exceptions at runtime instead of triggering compile-time failures.This had two problems:
THRUST_STATIC_ASSERTinside a class/struct template, the redefined macro would cause inscrutable build failures (nvcc errors like "expected a type specifier").Commit
096596b35removed the oldruntime_static_assert.h,unittest_static_assert.cu, andgenerate_const_iterators.cuwithout adding replacement compile tests. This issue remains open because the compile tests to replace them were never added.Additionally, the CMakeLists.txt still referenced the deleted
unittest_static_asserttest in athrust_declare_test_restrictionscall, which was stale.Change Made
New files
thrust/testing/generate_const_iterators_fail.cu: Compile-fail test that verifiesthrust::generatefails to compile when called with const iterators (v.cbegin(),v.cend()). The natural C++ type system enforces this — thegenerate_functor::operator()(T&&)tries to assign to aconst T&, which is a compile error.thrust/testing/fill_const_iterators_fail.cu: Compile-fail test that verifiesthrust::fillfails to compile when called with const iterators.Modified files
thrust/testing/CMakeLists.txt:thrust_is_fail_test()function to detect files named*_fail.*thrust_add_fail_test()function that creates a compile-fail test target usingcccl_add_xfail_compile_target_test(fromcmake/CCCLUtilities.cmake)_failtests from regular tests_failtests usingthrust_add_fail_testthrust_declare_test_restrictions(unittest_static_assert ...)for a test file that was deleted in096596b35The approach follows the exact same pattern already used by CUB (
cub/test/CMakeLists.txt) for compile-fail tests. Tests named*_fail.*are excluded from the regularalltarget and registered as CTest tests that pass when compilation fails (WILL_FAIL true).Issue
Fixes #807
Issue URL: #807
Changes
Testing
Agent ran relevant tests during development
Linting checks passed
Changes are minimal and focused on the issue
AI Assistance Disclosure
This pull request was prepared with the assistance of AI coding tools (GitHub Copilot). The change has been read, understood, and is owned by the human contributor submitting it, who will respond to review feedback.