test universal modules with LogosModuleContext#19
Open
dlipicar wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new universal C++ test module to validate LogosModuleContext lifecycle wiring (context properties + modules() + typed events), and extends the integration test runner / Nix flake outputs to build and execute it as part of the standard test suite.
Changes:
- Introduces
test_context_module_cpp(universal module) that readsLogosModuleContextproperties, makes cross-module calls viamodules(), and subscribes to typed events fromtest_basic_module_cpp. - Extends
tests/run_tests.shwith a newcontext-cpptest group that runs the new module with--persistence-pathand performs end-to-end assertions (including chained-cinvocations). - Updates
test_basic_module_cppto inheritLogosModuleContextand declare typed events vialogos_events:, plus wires the new module intoflake.nixoutputs and the combinedmodulesDir.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/run_tests.sh | Adds context-cpp group and helper to run the new module with --persistence-path. |
| test-context-module-cpp/src/test_context_module_cpp_impl.h | Declares the new module’s context accessors, cross-module calls, and event subscription methods. |
| test-context-module-cpp/src/test_context_module_cpp_impl.cpp | Implements the new module’s LogosModuleContext introspection, cross-module calls, and event subscriptions. |
| test-context-module-cpp/metadata.json | Defines the new universal module and its dependencies (test_basic_module, test_basic_module_cpp). |
| test-context-module-cpp/CMakeLists.txt | Adds build configuration for the new module via logos_module(...). |
| test-basic-module-cpp/src/test_basic_module_cpp_impl.h | Switches to LogosModuleContext inheritance and declares typed events under logos_events:. |
| test-basic-module-cpp/src/test_basic_module_cpp_impl.cpp | Updates event emission to call the typed event methods and adds bool-returning trigger helpers for CLI chaining. |
| flake.nix | Adds test_context_module_cpp to flake module outputs, install aggregation, and test modulesDir construction. |
Comments suppressed due to low confidence (1)
tests/run_tests.sh:495
- This comment says the liveness probe “returns the int 1 via a constant”, but the probe actually calls
wasContextReady()and assertsResult: true. Update the comment to reflect what’s being tested to avoid misleading future maintainers.
# Quick liveness probe: returns the int 1 via a constant — confirms
# the module loads and the codegen-emitted dispatch wires up before
# we start asserting context state. Failure here means the rest of
# the assertions are noise — the framework didn't even start.
echo ""
echo " -- Lifecycle hook fired --"
test_context_cpp "wasContextReady()" "Result: true" "test_context_module_cpp.wasContextReady()"
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Available groups: basic, basic-cpp, extlib, ipc, ipc-new-api, multi, errors, | ||
| # unit, unit-new-api | ||
| # Available groups: basic, basic-cpp, context-cpp, extlib, ipc, ipc-new-api, | ||
| # multi, errors, unit, unit-new-api |
Comment on lines
+514
to
+519
| # Instance ID: opaque host-generated short ID, just confirm it | ||
| # round-trips as a non-empty value. The "Result:" prefix is the | ||
| # CLI convention; the integration here is testing that the | ||
| # property propagated at all, not what shape the ID takes. | ||
| test_context_cpp "getInstanceId() non-empty" \ | ||
| "Result: " "test_context_module_cpp.getInstanceId()" |
Comment on lines
+63
to
+66
| // integration runner. The typed wrapper takes/returns Qt types | ||
| // (QString) because that's what the cpp-generator's client codegen | ||
| // emits today — the QString↔std::string bridge is the minimal price | ||
| // of admission and lives entirely in this .cpp. |
Comment on lines
+71
to
+73
| // The actual call site lives in the .cpp because the typed | ||
| // wrapper is generated against Qt types (QString in / out); the | ||
| // header stays Qt-free so the codegen parser doesn't get confused. |
Comment on lines
+110
to
+111
| // callbacks are registered with `&` capture so they write through | ||
| // to these members. |
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.
Summary
Adds a universal C++ test module —
test_context_module_cpp— that exercises every wire-up the newLogosModuleContextmixin provides, end-to-end, and rewires the integration runner so the existing CLI-driven check rig covers it.Concretely:
LogosModuleContextand surfaces all four kinds of context wiring as plainQ_INVOKABLEshims callable from logoscore:wasContextReady()delegates to the SDK'sisContextReady()(returnstrueonce the framework's_logosCoreSetContext_has populated the three getters and firedonContextReady()).getModulePath(),getInstanceId(),getInstancePersistencePath(), plushasInstanceId()andpersistencePathEndsWith(suffix)so the integration runner can make positive assertions against opaque host-generated values.callBasicEcho/callBasicAddIntsgo throughmodules().test_basic_module.<method>(...), exercising the fullonInit→std::make_unique<LogosModules>(api)→_logos_codegen_::maybeSetLogosModules(m_impl, ptr)→LogosModuleContext::_logosCoreSetLogosModulesPtr_chain at runtime, plus the typed<Module>wrapper at compile time.subscribeToBasicCppEvents()registersmodules().test_basic_module_cpp.onTestEvent(...)andonMultiArgEvent(...), capturing payloads into instance state;getLastTestEventData()/getLastMultiArgEvent()read them back. Used by the run-timesubscribe → trigger → readround-trip via chainedlogoscore -c.test_basic_module_cppover to the new mechanisms in the same PR: inheritsLogosModuleContext, declares its events in alogos_events:block, and exposes bool-returningtriggerTestEvent/triggerMultiArgEventshims (the void-returningemit*Q_INVOKABLE pair can't be chained vialogoscore -c).context-cppgroup totests/run_tests.sh(helpertest_context_cppalways passes--persistence-pathso the host provisions a per-instance dir against a tmpdir the test framework knows the prefix of) and wirestest_context_module_cppintoflake.nix's module outputs, install aggregation, andmodulesDirbuild.subscribe → trigger → readend-to-end cases under the context-cpp group that chaintest_context_module_cpp.subscribeToBasicCppEvents()→test_basic_module_cpp.triggerTestEvent(hello)→test_context_module_cpp.getLastTestEventData()in a singlelogoscoreinvocation, asserting the typed payload round-trips.CI failures on this PR are expected until logos-cpp-sdk#61 lands — they're caused by master's
logos-cpp-sdknot yet exposingLogosModuleContext,modules(), or thelogos_events:mechanism. With the SDK PR's branch overridden locally (logos-cpp-sdk,logos-module-builder,logos-plugin-qt,logos-plugin-coreall pointing at the matching worktree paths), the suite passes 169/169 (no flake).Review feedback addressed
1. "Available groups" list missing
async(Copilot,tests/run_tests.sh:23)Added
asyncto the comment-block enumeration.2. Misleading liveness-probe comment (Copilot,
tests/run_tests.sh:495, low-confidence note)The pre-existing comment claimed the probe "returns the int 1 via a constant" — leftover from an earlier version. Rewrote to describe what the assertion actually does:
3.
getInstanceId() non-emptyassertion was too weak (Copilot,tests/run_tests.sh:519)The original assertion just greps for the literal substring
Result:— which would pass for any string return, including empty. Replaced with a bool-returning helper on the impl:Result: trueonly appears when the underlying string is non-empty, so the assertion actually distinguishes "host populated the property" from "default-empty fallback".4. Stale Qt/QString comments on universal-typed code (Copilot,
test_context_module_cpp_impl.h:73andtest_context_module_cpp_impl.cpp:66)The header comment claimed the call site lives in the
.cppbecause "the typed wrapper is generated against Qt types (QString in / out)" and the cpp comment claimed "QString↔std::string bridge ... lives entirely in this .cpp." Both wrong — the module isinterface: "universal", so the dep wrappers are std-typed and no bridge is needed. Rewrote both to say so:5. Wrong capture-mode comment on subscription state (Copilot,
test_context_module_cpp_impl.h:111)Comment said "callbacks are registered with
&capture" but the actual lambdas insubscribeToBasicCppEvents()capture[this]. Corrected:Test plan
nix build .#checks.aarch64-darwin.testsfromrepos/logos-test-moduleswith the four overrides (logos-cpp-sdk,logos-module-builder,logos-plugin-qt,logos-plugin-coreall overridden to the matching worktree branches) — 169 passed, 0 failed, 25 skipped of 169 run.wasContextReady), getters (3× context properties +hasInstanceId), cross-module calls (callBasicEcho,callBasicAddInts), and typed event subscriptions (subscribeToBasicCppEvents+testEvent/multiArgEventround-trips via chained-c).🤖 Generated with Claude Code