Skip to content

EVEREST_CORE_BUILD_TESTING seems to require LIBEVSE_SECURITY_BUILD_TESTING or others #1675

@barsnick

Description

@barsnick

Describe the bug

It seems the recent inclusion of everest-dev-environment has changed how to build unit tests.

Version: everest-core @ af82e4bb33d862901ac33909bdb58a81608f9543

I am trying to debug a unit test failure in the GitHub CI, by reproducing it locally, in my Linux VM. I am used to building the tests like this:

(cd build/ && cmake -DEVEREST_CORE_BUILD_TESTING=ON ..)

or

(cd build/ && cmake -DCMAKE_BUILD_TYPE=Release -DEVEREST_CORE_BUILD_TESTING=ON ..)

But now, I am getting CMake errors from various sub-projects looking for GTest:

-- Configuring done (24.7s)
CMake Error at modules/API/API/tests/CMakeLists.txt:18 (target_link_libraries):
  Target "everest-core_API_tests" links to:

    GTest::gtest_main

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.



CMake Error at modules/EnergyManagement/EnergyManager/tests/CMakeLists.txt:32 (target_link_libraries):
  Target "everest-core_EnergyManager_tests" links to:

    GTest::gmock

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.
[...]

(A total of 18 GTest related failures.)

This even happens on a fresh checkout, and also if googletest is installed locally (although I expect it to come from EDM via dependencies.yaml).

The relevant log entries are:

[edm]: Dependency "gtest": "release-1.12.1" is a tag

BUT:

-- Excluding dependency gtest based on cmake_condition

The latter message comes multiple times, in all the affected sub-projects. It seems due to this blob in build/dependencies.cmake and similar ones in all the other template-created dependencies.cmake:

if("gtest" IN_LIST EVEREST_EXCLUDE_DEPENDENCIES)
    message(STATUS "Excluding dependency gtest")
elseif(EVEREST_LIBLOG_BUILD_TESTING)
CPMAddPackage(
    NAME gtest
    GIT_REPOSITORY https://github.com/google/googletest.git
    GIT_TAG release-1.12.1
)
else()
    message(STATUS "Excluding dependency gtest based on cmake_condition")
endif()

created by EDM through applications/dev-environment/dependency_manager/src/edm_tool/templates/cpm.jinja.

It seems that EVEREST_CORE_BUILD_TESTING pulls in testing in all subprojects, but each project's dependencies require a different explicit config variable (LIBOCPP_BUILD_TESTING, LIBTIMER_BUILD_TESTING, EVEREST_LIBLOG_BUILD_TESTING, ...)

(Same problem for Catch2, by the way,)

If I change my CMake call to enable even only one of those separate variables, e.g.:

(cd build/ && cmake -DEVEREST_CORE_BUILD_TESTING=ON -DLIBEVSE_SECURITY_BUILD_TESTING=ON ..)

then CMake completes successfully. (It seems activating one of those variables is enough to pull GTest in, and to satisfy all other projects, even though their depedencies.cmake still report "Excluding dependency gtest based on cmake_condition").

This looks fishy to me.

EVerest Domain

Compilation, Testing

Affected EVerest Module

CMake
EDM

To Reproduce

No response

Anything else?

No response

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions