Add native C++ ctest suite#1162
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## pre-release #1162 +/- ##
============================================
Coverage 54.51% 54.51%
============================================
Files 70 70
Lines 7862 7862
Branches 1179 1179
============================================
Hits 4286 4286
Misses 3300 3300
Partials 276 276 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds a first native C++ test suite under tests/cpp/ and wires it into the main CMake/CTest flow, while also replacing the legacy standalone tests/api_test executable with a CTest-managed API smoke test. This also includes two small product bug fixes uncovered by the new deterministic coverage.
Changes:
- Introduce a native C++ doctest-compatible harness + shared test support target and add initial deterministic unit tests + a Python-backed API smoke test.
- Integrate the native suite into top-level CMake/CTest and CI (CTest labels for selection).
- Fix two runtime bugs: zero-length safety in memory bit helpers and Pool destructor queue draining.
Reviewed changes
Copilot reviewed 27 out of 28 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
CMakeLists.txt |
Adds ROGUE_BUILD_TESTS option and wires tests/cpp into the main build/CTest flow. |
.github/workflows/rogue_ci.yml |
Updates CI to build via cmake -S/-B and run labeled native CTest suites in both Python and no-Python jobs. |
src/rogue/interfaces/memory/Master.cpp |
Fixes zero-length handling in copyBits, setBits, and anyBits. |
src/rogue/interfaces/stream/Pool.cpp |
Fixes destructor draining logic by popping the queue after free(). |
tests/README.md |
Updates test layout docs to include the new native C++ suite and CTest commands. |
tests/BRANCH_STATUS.md |
Adds branch handoff/status documentation for the broader test/coverage effort. |
tests/NEXT_STEPS.md |
Adds follow-up checklist and recommended validation commands. |
tests/cpp/CMakeLists.txt |
Adds shared test support library and rogue_add_cpp_test() helper; registers sub-suites and labels. |
tests/cpp/README.md |
Documents native C++ suite structure, labels, and common build/run commands. |
tests/cpp/vendor/doctest/doctest.h |
Adds in-tree minimal doctest-compatible single-header test harness. |
tests/cpp/support/test_main.cpp |
Adds shared test runner main() with optional embedded Python/NumPy bootstrap. |
tests/cpp/support/test_python.h |
Declares shared Python/NumPy initialization helper for smoke tests. |
tests/cpp/support/test_helpers.h |
Adds shared stream pool/frame helpers and a polling helper for async assertions. |
tests/cpp/core/CMakeLists.txt |
Registers core native test targets and labels. |
tests/cpp/core/test_version.cpp |
Adds deterministic tests for rogue::Version helpers and validation behavior. |
tests/cpp/memory/CMakeLists.txt |
Registers memory native test targets and labels. |
tests/cpp/memory/test_memory_bits.cpp |
Adds deterministic tests for memory bit helper routines, including zero-length behavior. |
tests/cpp/memory/test_transaction_block.cpp |
Adds deterministic tests for block transaction sequencing/min-access expansion/verify mismatch behavior. |
tests/cpp/memory/test_variable.cpp |
Adds deterministic tests for variable metadata, offset shifting, typed accessor rejection, and list stride/range checks. |
tests/cpp/stream/CMakeLists.txt |
Registers stream native test targets and labels. |
tests/cpp/stream/test_frame_pool.cpp |
Adds deterministic tests for pool allocation, multi-buffer frame behavior, append semantics, and payload helpers. |
tests/cpp/stream/test_iterator.cpp |
Adds deterministic tests for frame iterator traversal, payload vs capacity, and iterator-driven copies. |
tests/cpp/stream/test_fifo_filter_rate_drop.cpp |
Adds deterministic tests for FIFO trim/drop behavior, filter rules, and RateDrop count-mode behavior. |
tests/cpp/smoke/CMakeLists.txt |
Registers Python-required API smoke test and labels. |
tests/cpp/smoke/test_api_smoke.cpp |
Adds embedded-Python API smoke test exercising rogue::interfaces::api::Bsp against a minimal in-test module/root. |
tests/api_test/README.md |
Marks legacy standalone API test path as deprecated in favor of CTest smoke. |
tests/api_test/src/api_test.cpp |
Removes legacy standalone sample executable source. |
tests/api_test/CMakeLists.txt |
Removes legacy standalone sample build system. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 27 out of 28 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…RE_MESSAGE, and FAIL macros
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 27 out of 28 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description
This branch adds the first native C++ regression suite under
tests/cpp/and wires it into the main CMake/CTest flow. The new coverage stays intentionally narrow and fast. It implements deterministic native tests for version helpers, memory bit helpers, stream frame/pool behavior, and stream iterator behavior, plus a Python-enabled API smoke test managed by CTest.This change also replaces the old standalone
tests/api_testsample executable with a CTest-managed smoke test, updates the test documentation to describe how the native suite is built and run from the standardbuild/tree, and updates CI so the native test labels run as part of the existing build jobs.Details
The native test system is added behind
ROGUE_BUILD_TESTSin the top-level CMake build and uses an in-tree single-header doctest-compatible harness plus a shared support target so individual test files stay focused on behavior. The suite is organized undertests/cpp/by subsystem and uses CTest labels (cpp,cpp-core,no-python,requires-python,smoke) to keep local runs and CI selection predictable.Two product bugs were exposed while building the deterministic native coverage and are fixed here:
src/rogue/interfaces/memory/Master.cppThe
copyBits,setBits, andanyBitshelpers all use ado { ... } while (...)structure after initializingrem = size. Whensize == 0, the old code still executed the loop body once before checking termination. That made zero-length operations unsafe: a no-op request could still calculate masks, read source bits, inspect destination bits, or write into the destination buffer even though no bits were requested. The fix adds an immediate zero-length return at the top of each helper, preserving the expected semantics:copyBitsandsetBitsbecome true no-ops, andanyBitsreturnsfalsewithout touching memory.src/rogue/interfaces/stream/Pool.cppThe pool destructor previously freed
dataQ_.front()insidewhile (!dataQ_.empty())but never removed the front element from the queue. In practice that means the destructor repeatedly frees the same pointer while the queue never advances, which can lead to double-free behavior or an infinite drain loop during teardown. The fix pops the queue entry after eachfree()so the destructor actually walks and releases every pooled allocation exactly once.