Skip to content

[codex] increase CLIPipeline test coverage for info/anim/validate/lod branches - #255

Merged
fernandotonon merged 7 commits into
masterfrom
codex/coverage-boost-90
Apr 8, 2026
Merged

[codex] increase CLIPipeline test coverage for info/anim/validate/lod branches#255
fernandotonon merged 7 commits into
masterfrom
codex/coverage-boost-90

Conversation

@fernandotonon

@fernandotonon fernandotonon commented Apr 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • add targeted CLIPipeline tests that exercise additional cmdInfo, cmdAnim, cmdValidate, and cmdLod branch paths
  • add a reusable helper to generate/export temporary in-memory meshes for CLI command tests
  • focus on coverage gains in CLI command code paths that were under-tested after recent merges

Why

Coverage regressed after merges, with notable gaps in CLI command handling branches. These tests target previously untested decision paths and error/success flows using generated meshes instead of external fixtures.

Validation

  • cmake --build . --target UnitTests -j6
  • ./bin/UnitTests --gtest_filter='CLIPipelineFormatForExtension.CaseInsensitive'
  • xvfb-run -a ./bin/UnitTests --gtest_filter='CLIPipelineCmdTest.CmdInfo_InvalidExistingFile:CLIPipelineCmdTest.CmdAnimList_NoAnimationsReturnsSuccess:CLIPipelineCmdTest.CmdAnimMerge_WithoutSourcesReturnsError:CLIPipelineCmdValidateTest.CmdValidate_SucceedsForGeneratedMeshTextAndJson:CLIPipelineCmdLodTest.CmdLod_InfoAndRemoveFromGeneratedMesh' (local env reports Ogre unavailable so these skip locally; CI environment will run with project CI setup)

Summary by CodeRabbit

  • Tests
    • Expanded CLI pipeline in-process tests with new error and success scenarios for invalid inputs, missing animations/sources, and merge edge cases.
    • Added coverage for validation and LOD info/remove workflows, checking both text and JSON outputs and produced artifacts.
    • Introduced a test-only helper that generates and exports temporary triangle/skeleton meshes for use in tests.
    • Improved UI test stability by increasing retry attempts, adding exponential backoff, extra cleanup, and event processing between attempts.

@coderabbitai

coderabbitai Bot commented Apr 8, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a test-only helper to generate/export an in-memory Ogre triangle mesh and extends CLI in-process tests (cmdInfo, cmdAnim --list/--merge, cmdValidate, cmdLod) to exercise error and success paths using exported temp meshes; also increases MainWindow construction retry attempts and introduces Manager::kill()/event-processing and attempt-scaled backoff across several widget/view tests.

Changes

Cohort / File(s) Summary
CLI tests & mesh helper
src/CLIPipeline_test.cpp
Added static QString exportGeneratedTriangleMesh(const QString& baseName) to create an in-memory Ogre triangle mesh, remove pre-existing baseName.mesh/.material, export via MeshImporterExporter::exporter, destroy created Ogre objects, and return temp path or empty string. Expanded CLIPipeline in-process tests: added error and success scenarios for cmdInfo, cmdAnim --list/--merge, cmdValidate, and cmdLod covering text and --json modes and cleaning up temp files and Ogre objects.
MainWindow retry/backoff in widget tests
src/OgreWidget_test.cpp, src/EditorViewport_test.cpp, src/SpaceCamera_test.cpp, src/ViewCube/ViewCubeController_test.cpp
Increased MainWindow construction retries (mostly 3→6 or 5→6), added Manager::kill() before/after attempts, call app->processEvents() between attempts, added short pre-attempt sleep, and replaced fixed retry waits with an attempt-scaled backoff 200 * attempt ms. Minor adjustments to inter-attempt timing and error-path cleanup.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Test as Test runner
participant Ogre as Ogre scene (node/entity)
participant Exporter as MeshImporterExporter::exporter
participant FS as Filesystem (temp .mesh/.material)
participant CLI as CLIPipeline (cmdInfo/cmdAnim/cmdValidate/cmdLod)
Test->>Ogre: create in-memory triangle mesh/entity
Ogre-->>Test: return scene node/entity handle
Test->>FS: remove existing baseName.mesh/.material
Test->>Exporter: export node/entity -> temp .mesh
Exporter-->>FS: write temp .mesh/.material
Test->>Ogre: destroy/dereference created node/entity
Test->>CLI: run cmd (info/anim/validate/lod) on temp .mesh
CLI->>FS: read temp .mesh / write outputs (e.g., removedOut.mesh)
Test->>FS: verify outputs, then remove temp files

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰
I shaped a triangle, tidy and neat,
I sent it out on tiny mesh feet,
Tests hopped by, they peeked and they played,
Files cleaned up, no crumbs were displayed,
I nibble on code and celebrate sweet.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main focus of the changeset: adding targeted CLIPipeline tests for previously under-tested branches (info/anim/validate/lod).
Description check ✅ Passed The description follows the template structure with Summary and Technical Details sections, clearly explaining what was added, why coverage was needed, and how to validate the changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/coverage-boost-90

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/CLIPipeline_test.cpp`:
- Around line 1049-1084: The test TEST_F(CLIPipelineCmdTest,
CmdAnimList_NoAnimationsReturnsSuccess) is asserting success (0) for
CLIPipeline::cmdAnim when a mesh has zero animations, but the command contract
defines this as an error (return 1); update the two expectations calling
CLIPipeline::cmdAnim (the non-JSON and JSON invocations created via TestArgv
textArgs and jsonArgs) to expect 1 instead of 0 so the test matches the command
behavior (or alternatively rename the test and change CLIPipeline::cmdAnim if
you intend to change the command contract).
- Around line 666-685: The helper exportGeneratedTriangleMesh(...) creates a
mesh, scene node and entity but never tears them down, leaking scene state;
after the export (before each return) call the appropriate teardown:
remove/destroy the created Entity and SceneNode via the Manager singleton (e.g.,
use Manager::getSingleton()->destroyEntity(entity) or removeSceneNode(nodeName)
/ removeSceneNode(node) and then destroy the node), and also remove the
in-memory mesh from Ogre::MeshManager (e.g.,
Ogre::MeshManager::getSingleton().remove(meshName) or equivalent) so the mesh,
entity and node are fully cleaned up before returning; ensure these teardown
calls run on both success and failure paths in exportGeneratedTriangleMesh.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1a496d13-449d-4223-856b-b623b215302e

📥 Commits

Reviewing files that changed from the base of the PR and between 34fe349 and 31a9169.

📒 Files selected for processing (1)
  • src/CLIPipeline_test.cpp

Comment thread src/CLIPipeline_test.cpp
Comment thread src/CLIPipeline_test.cpp Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/CLIPipeline_test.cpp (1)

1069-1104: Consider removing the in-memory mesh from MeshManager after export for test isolation.

The mesh created by createInMemorySkeletonMesh("cli_no_anim_mesh") remains in Ogre::MeshManager after the test completes. While scene objects are properly cleaned up (lines 1089-1093), the mesh resource persists. If tests are run repeatedly in the same process, this could cause conflicts or stale state.

Suggested cleanup addition
     auto nodes = manager->getSceneNodes();
     for (auto* n : nodes) {
         manager->destroyAllAttachedMovableObjects(n);
         manager->destroySceneNode(n);
     }
+    if (auto old = Ogre::MeshManager::getSingleton().getByName("cli_no_anim_mesh"))
+        Ogre::MeshManager::getSingleton().remove(old);

     QByteArray sourceBa = sourceFile.toUtf8();
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/CLIPipeline_test.cpp` around lines 1069 - 1104, The test leaves the
in-memory mesh created by createInMemorySkeletonMesh("cli_no_anim_mesh")
registered in Ogre::MeshManager, so after exporting and tearing down the scene
you should explicitly remove/unregister that mesh from MeshManager to avoid
cross-test pollution; locate the mesh variable (mesh) created in
CmdAnimList_NoAnimationsGeneratedMeshReturnsError and after destroying scene
nodes (or immediately after exporter calls) call the appropriate MeshManager
singleton remove/unload method for mesh->getName() (or remove the resource by
name "cli_no_anim_mesh") to ensure the resource is removed from
Ogre::MeshManager before the test exits.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/CLIPipeline_test.cpp`:
- Around line 1069-1104: The test leaves the in-memory mesh created by
createInMemorySkeletonMesh("cli_no_anim_mesh") registered in Ogre::MeshManager,
so after exporting and tearing down the scene you should explicitly
remove/unregister that mesh from MeshManager to avoid cross-test pollution;
locate the mesh variable (mesh) created in
CmdAnimList_NoAnimationsGeneratedMeshReturnsError and after destroying scene
nodes (or immediately after exporter calls) call the appropriate MeshManager
singleton remove/unload method for mesh->getName() (or remove the resource by
name "cli_no_anim_mesh") to ensure the resource is removed from
Ogre::MeshManager before the test exits.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4c8e2e35-101b-4fe2-97c8-2fb9eaea825b

📥 Commits

Reviewing files that changed from the base of the PR and between 3d987ef and 49d6f52.

📒 Files selected for processing (1)
  • src/CLIPipeline_test.cpp

@sonarqubecloud

sonarqubecloud Bot commented Apr 8, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant