From 015f55cd82c04aeec5ca7e057d5b9c738d9609e7 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Wed, 1 Mar 2023 13:03:07 +0300 Subject: [PATCH] vcmi: fix building tests without scripts --- test/CMakeLists.txt | 79 ++++++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 36 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index eb6f05669..2549ee6d9 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -30,22 +30,6 @@ set(test_SRCS entity/CHeroTest.cpp entity/CSkillTest.cpp - erm/ERM_BM.cpp - erm/ERM_BU.cpp - erm/ERM_FU.cpp - erm/ERM_GM_T.cpp - erm/ERM_MA.cpp - erm/ERM_MC.cpp - erm/ERM_MF.cpp - erm/ERM_TM_T.cpp - erm/ERM_VR.cpp - erm/ERM_UN.cpp - erm/ERMPersistenceTest.cpp - erm/ExamplesTest.cpp - erm/interpretter/ERM_VR.cpp - erm/interpretter/ERM_UN.cpp - erm/interpretter/ErmRunner.cpp - events/ApplyDamageTest.cpp events/EventBusTest.cpp @@ -58,12 +42,6 @@ set(test_SRCS netpacks/EntitiesChangedTest.cpp netpacks/NetPackFixture.cpp - scripting/LuaSandboxTest.cpp - scripting/LuaSpellEffectTest.cpp - scripting/LuaSpellEffectAPITest.cpp - scripting/PoolTest.cpp - scripting/ScriptFixture.cpp - spells/AbilityCasterTest.cpp spells/CSpellTest.cpp spells/TargetConditionTest.cpp @@ -105,10 +83,7 @@ set(test_HEADERS CVcmiTestConfig.h JsonComparer.h - scripting/ScriptFixture.h - erm/interpretter/ErmRunner.h - - map/MapComparer.h + map/MapComparer.h netpacks/NetPackFixture.h @@ -126,6 +101,44 @@ set(test_HEADERS ) +if(ENABLE_LUA) + list(APPEND test_SRCS + scripting/LuaSandboxTest.cpp + scripting/LuaSpellEffectTest.cpp + scripting/LuaSpellEffectAPITest.cpp + scripting/PoolTest.cpp + scripting/ScriptFixture.cpp + ) + + list(APPEND test_HEADERS + scripting/ScriptFixture.h + ) +endif() + +if(ENABLE_ERM) + list(APPEND test_SRCS + erm/ERM_BM.cpp + erm/ERM_BU.cpp + erm/ERM_FU.cpp + erm/ERM_GM_T.cpp + erm/ERM_MA.cpp + erm/ERM_MC.cpp + erm/ERM_MF.cpp + erm/ERM_TM_T.cpp + erm/ERM_VR.cpp + erm/ERM_UN.cpp + erm/ERMPersistenceTest.cpp + erm/ExamplesTest.cpp + erm/interpretter/ERM_VR.cpp + erm/interpretter/ERM_UN.cpp + erm/interpretter/ErmRunner.cpp + ) + + list(APPEND test_HEADERS + erm/interpretter/ErmRunner.h + ) +endif() + assign_source_group(${test_SRCS} ${test_HEADERS}) set(mock_HEADERS @@ -170,16 +183,10 @@ target_include_directories(vcmitest PRIVATE ${GMockSrc}/include ) -if(FALSE AND NOT ${CMAKE_VERSION} VERSION_LESS "3.10.0") - # Running tests one by one using ctest not recommended due to vcmi having - # slow global initialization. - gtest_discover_tests(vcmitest - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/bin/") -else() - add_test(NAME tests - COMMAND vcmitest - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/bin/") -endif() +# Running tests one by one using ctest not recommended due to vcmi having +# slow global initialization. +gtest_discover_tests(vcmitest + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/bin/") vcmi_set_output_dir(vcmitest "")