test: fix cpp_tests build and add CI gate#32
Conversation
The two regression tests added in PR #23 (stereo SaveSettings preset round-trip + malformed right_uv) use a nested `json::array({ json{ {k,v}, {k,v} } })` construction that MSVC's C++23 module-aware parse cannot disambiguate against the `initializer_list<initializer_list< json>>` overload of `nlohmann::json`'s constructor. The compiler emits C3329 ("expected '}' not ')'") at what appears to be a correctly-balanced closing paren, then cascades into a stream of nonsense errors (C3484, C3613, C2086 "int src: redefinition") that look like wholly different problems but are all downstream of the initial parse failure. CI green at merge time because the cpp_tests target wasn't included in the workflow's `run_shader_tests` step. Fix: build the preset json by mutation (`preset["name"] = ...`) rather than a single nested initializer-list. Identical semantics, no parse-time ambiguity. Suite is now 54 assertions / 17 cases, all passing on a clean build off origin/dev. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
No actionable suggestions for changed features. |
There was a problem hiding this comment.
Pull request overview
Fixes MSVC (VS 2022/2026) C++23 module-aware parsing failures in the C++ regression tests by avoiding an ambiguous nlohmann::json brace-initialization pattern, ensuring the cpp_tests target compiles locally under that toolchain mode.
Changes:
- Reworks JSON construction in the stereo
SaveSettingspreset round-trip regression test to build the preset object via direct mutation before wrapping it injson::array(...). - Applies the same construction pattern to the malformed
right_uvfallback regression test to avoid the same MSVC parsing ambiguity.
Mirrors the shader_tests pattern so cpp_tests is built and run only when relevant files change (and always on push / workflow_dispatch / release events). pr-checks.yaml: - New `cpp_tests` files_yaml category: `tests/cpp/**` - New `cpp-tests-should-build` output combining cpp_tests + cpp (since the target compiles src/Utils/Subrect.cpp directly per tests/cpp/CMakeLists.txt — conservative-but-correct) + cmake + build_ci. Falls through to true on changed-files failure. - New `run-cpp-tests` and `cpp-tests-should-build` inputs passed into _shared-build.yaml. _shared-build.yaml: - New `run-cpp-tests` (boolean, default true) and `cpp-tests-should-build` (string, default "true") inputs. - New `cpp-unit-tests` job parallel to `shader-unit-tests`. Builds the `cpp_tests` target and runs `ctest -R CppUtilTests`. Gated inline (no composite action — the single branch is too small for the indirection). Without this gate, the PR #23 stereo Subrect tests broke the cpp build but CI stayed green because `--target shader_tests` never touched the cpp_tests source files. Next time a cpp_tests test fails to compile, this gate catches it at PR-check time. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
CodeQL alert triageThe CodeQL "Cache Poisoning via execution of untrusted code" alert (#15) fires on the new So the alert is a pre-existing repo-wide architectural concern that this PR merely surfaces by adding a fourth instance of the same shape. Fixing it in this PR would require refactoring Recommend dismissing alert #15 as "won't fix / accepted risk" with the same justification used implicitly for the other three jobs, or opening a separate hardening PR if you'd like to restructure the trigger model. Not blocking this PR. |
|
✅ A pre-release build is available for this PR: |
Summary
Two related changes — fix the broken cpp_tests build, then wire CI to catch the next regression of the same shape.
Part 1: Make cpp_tests compile under MSVC C++23 modules
The two regression tests added in #23 (stereo
SaveSettingspreset round-trip + malformedright_uvfallback) don't compile under MSVC's C++23 module-aware parse. The build fails with a misleading cascade of errors starting with C3329 (expected '}' not ')') at what appears to be a correctly-balanced closing paren.Root cause:
json::array({ json{ {k,v}, {k,v} } })is ambiguous between twonlohmann::jsonconstructor overloads. MSVC's parser falls into the wrong overload, fails inside it, and the displayed error column points at the inner closing)rather than the actual ambiguity site.Fix: build the preset object via direct mutation (
preset["name"] = ...) before placing it into the outerjson::array(...). Identical semantics, no parse-time ambiguity.Part 2: Gate cpp_tests on changed files in CI
CI was green at #23's merge because the
cpp_teststarget isn't built or run by any workflow:_shared-build.yaml:246explicitly targets--target shader_testsonly-R ShaderTestswould skipCppUtilTestseven if the binary existedMirrored the shader_tests pattern:
pr-checks.yaml: newcpp_testsfiles_yaml category (tests/cpp/**) andcpp-tests-should-buildoutput combining cpp_tests / cpp / cmake / build_ci changes. Thecppcategory is conservative-but-correct sincecpp_testscompilessrc/Utils/Subrect.cppdirectly (pertests/cpp/CMakeLists.txt), so any cpp change could affect it._shared-build.yaml: newrun-cpp-tests(boolean) andcpp-tests-should-build(string) inputs; newcpp-unit-testsjob parallel toshader-unit-teststhat builds--target cpp_testsand runsctest -R CppUtilTests. Gated inline (no composite action — single branch isn't worth the indirection).Verification
cpp_tests.exebuilds and 54 assertions / 17 cases pass on a clean build offorigin/dev(Part 1 fix).github/workflows/**(build_ci) andtests/cpp/**(cpp_tests) — self-validates the gate🤖 Generated with Claude Code