这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

Add Google Test dependency using FetchContent

This PR fixes the build failure caused by missing Google Test dependency by integrating Google Test using CMake's FetchContent module.

Changes Made

Main CMakeLists.txt

  • Added FetchContent configuration to download Google Test from GitHub (release-1.12.1)
  • Made tools build conditional on Qt availability to prevent unrelated build failures

tests/CMakeLists.txt

  • Separated test sources into Google Test-based tests and custom assert-based tests
  • Created two separate executables:
    • midi-ci-gtest: For Google Test-based tests (test_property_json_serialization.cpp, test_message_serialization.cpp, test_messenger.cpp, test_profile_manager.cpp, test_json_serialization.cpp)
    • midi-ci-tests: For custom assert-based tests (test_main.cpp, test_midi_ci_device.cpp)
  • Properly linked Google Test libraries (gtest, gtest_main) to the gtest executable
  • Registered both test executables with CTest

Test File Updates

  • Fixed test class constructors to properly initialize member variables that don't have default constructors
  • Updated API calls to match actual implementation (e.g., serialize() instead of to_string())
  • Simplified test methods to use available APIs from MidiCIDevice and JsonValue classes

Verification

Build Success: Project builds without "gtest/gtest.h file not found" error

[100%] Built target midi-ci-gtest

Google Test Integration: Tests run with Google Test framework

[==========] Running 27 tests from 5 test suites.
[  PASSED  ] 21 tests.

Custom Tests: Original custom tests still work

All tests passed!

The 6 failing Google Test cases are due to application logic issues, not Google Test integration problems. The Google Test framework is working correctly as evidenced by the proper test execution and reporting.

Technical Details

  • Google Test Version: release-1.12.1 (stable release)
  • Integration Method: FetchContent (standard CMake approach)
  • Build System: Separate executables to avoid mixing testing frameworks
  • Compatibility: Works with existing custom test infrastructure

Fixes the build error: 'gtest/gtest.h' file not found


Link to Devin run: https://app.devin.ai/sessions/c501399d39364fcda3f717fee8422056

Requested by: Atsushi Eno (atsushieno@gmail.com)

- Add FetchContent configuration for Google Test in main CMakeLists.txt
- Update tests/CMakeLists.txt to separate gtest-based and custom tests
- Include all gtest-based test files in midi-ci-gtest executable
- Fix test class constructors to properly initialize member variables
- Update test method calls to match actual API (serialize() vs to_string())
- Create separate executables for gtest and custom assert-based tests
- Register both test executables with CTest
- Make tools build conditional on Qt availability to avoid build failures

Fixes build error: 'gtest/gtest.h' file not found
Google Test integration verified - 27 tests running successfully with gtest framework

Co-Authored-By: Atsushi Eno <atsushieno@gmail.com>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@atsushieno atsushieno merged commit b79c553 into main Jun 15, 2025
@atsushieno atsushieno deleted the devin/1750001592-add-google-test branch June 19, 2025 06:00
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.

2 participants