add workspace manager unit tests#32861
Conversation
📝 WalkthroughWalkthroughAdds a workspace test suite: two GMock-based mocks, test environment setup, three WorkspaceManager tests, and CMake entries to build the test module. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
18e7b54 to
c10aa51
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: a3397d9a-88a8-4211-8081-9cc7f9022c16
📒 Files selected for processing (6)
src/framework/multiwindows/tests/mocks/multiwindowsprovidermock.hsrc/framework/workspace/CMakeLists.txtsrc/framework/workspace/tests/CMakeLists.txtsrc/framework/workspace/tests/environment.cppsrc/framework/workspace/tests/mocks/workspaceconfigurationmock.hsrc/framework/workspace/tests/workspacemanager_tests.cpp
| if (MUSE_MODULE_WORKSPACE_TESTS) | ||
| add_subdirectory(tests) | ||
| endif() |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify declaration and usage of the workspace tests toggle.
rg -n --type=cmake -C2 '\bMUSE_MODULE_WORKSPACE_TESTS\b'Repository: musescore/MuseScore
Length of output: 350
Add or declare the MUSE_MODULE_WORKSPACE_TESTS toggle before use.
The variable MUSE_MODULE_WORKSPACE_TESTS is checked at line 57 but is never declared or set anywhere in the codebase. In CMake, undefined variables evaluate to false in conditionals, which means the tests directory will never be included regardless of intent. Either remove this check if tests are always needed, or declare the option/variable (e.g., option(MUSE_MODULE_WORKSPACE_TESTS "Enable workspace tests" OFF)) in the parent CMakeLists.txt or cmake configuration.
| void TearDown() override | ||
| { | ||
| m_manager.reset(); | ||
| modularity::globalIoc()->unregister<mi::IMultiWindowsProvider>("utests"); | ||
| } |
There was a problem hiding this comment.
Move manager deinitialization into TearDown() for guaranteed cleanup.
Right now cleanup depends on reaching the end of each test body. A fatal assertion can skip deinit() and leave state behind for subsequent tests.
Proposed fix
void TearDown() override
{
- m_manager.reset();
+ if (m_manager) {
+ m_manager->deinit();
+ m_manager.reset();
+ }
modularity::globalIoc()->unregister<mi::IMultiWindowsProvider>("utests");
}
@@
- m_manager->deinit();
}
@@
- m_manager->deinit();
}
@@
- m_manager->deinit();
}Also applies to: 118-119, 143-144, 169-170
Resolves: add workspace manager unit tests
Summary by CodeRabbit