Files
ForeverCore/tests/CMakeLists.txt
Karrz1 69f6f6249c
Ubuntu x64 / build (clang-17, clang++-17, <nil>, 1) (push) Waiting to run
Ubuntu x64 / build (clang-17, clang++-17, ccache, 0) (push) Waiting to run
Ubuntu x64 / build (gcc-13, g++-13, <nil>, 1) (push) Waiting to run
macOS arm64 / build (push) Waiting to run
Windows x64 / build (push) Waiting to run
Bots: hired bots (sellsword brokers) in the bot module, as their own part (Hire/)
The hire brokers were in the world database without their code, so for a server built from this source the
Sellsword Captains, Veteran Recruiters and Black Market Brokers did nothing. Here is the code, as it runs in the
WoW Forever Bots repack, built so it can be left out or replaced:

- Hire/: the brokers' gossip (npc_fb_hire_broker), the contracts (HireMgr), the rules (HirePolicy.h: prices,
  grades, upkeep, who must hire) and HireModule.cpp, which registers them. Hire/README.md explains the grades,
  the Playerbot.Hire.* settings, the commands and how another hire module plugs in.
- HireHooks.h/.cpp and HireTypes.h: the one door between the bot module and hired bots. `.bot add`, `.bot call`,
  `.bot delete`, the Group Finder, companion upkeep, gear and the add-on ask Fleet::Hiring(); without a hire
  module the answer is "no hired bots" and companions are free as before.
- CMake option PLAYERBOT_V2_HIRE (default on). Off: `.bot hire` and the brokers say there are no hired bots.
- `.bot hire [on|off]`, the ForeverBots add-on's hired-bots-only view (ForeverBots_Hire.lua, /fb hire), the
  Playerbot.Hire.* settings in playerbot.conf.dist (Mode 0 = off by default).
- SQL: the 39 brokers and their gossip menu (world, same files as the repack), the contracts table
  (sql/playerbot_v2/0037_hired_bots.sql, applied by the module at start).
- tests/game/ClassicHirePolicy.cpp pins the rules.
2026-11-24 11:30:11 +00:00

146 lines
5.1 KiB
CMake

# This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
GroupSources(${CMAKE_CURRENT_SOURCE_DIR})
option(HEADLESS_TESTS "Build the headless packet-level client tests (tests/headless), run against a test realm" 0)
add_executable(tests)
# The source folder, for tests that read source files (the compiler trims __FILE__ in release builds, so it cannot be derived from there).
target_compile_definitions(tests PRIVATE TC_SOURCE_DIR="${CMAKE_SOURCE_DIR}")
CollectAndAddSourceFiles(
tests
${CMAKE_CURRENT_SOURCE_DIR}
EXCLUDE
${CMAKE_CURRENT_SOURCE_DIR}/tools
${CMAKE_CURRENT_SOURCE_DIR}/headless)
# Tests of code that lives in the Playerbot V2 module's own sources (they call functions defined in the module's .cpp files, or include
# headers that exist only under src/modules/PlayerbotV2). A build without the module has neither, so they are not compiled there.
if(NOT BUILD_PLAYERBOT_V2)
set(TESTS_MODULE_ONLY_SOURCES
ClassicAddonHint.cpp
ClassicTalentCode.cpp
ClassicBotBridge.cpp
ClassicBotConversation.cpp
ClassicChannelTalk.cpp
ClassicPartyTalk.cpp
ClassicBotMigrations.cpp
ClassicGuildAskText.cpp
ClassicBotLocale.cpp
ClassicCompanionLeash.cpp
ClassicHirePolicy.cpp
ClassicMeleeReach.cpp
ClassicFalseCombatEscape.cpp
ClassicFollowDrop.cpp
ClassicBotSwim.cpp
ClassicGroupControl.cpp
ClassicGroupFight.cpp
ClassicGroupOrderText.cpp
ClassicCcDeny.cpp
ClassicOwnerPicks.cpp
ClassicAoeDeny.cpp
ClassicCompanionDelete.cpp
ClassicHumanLogin.cpp
ClassicInstanceFullHold.cpp
ClassicArmorSwapGate.cpp
ClassicArmorTypeFit.cpp
ClassicBotCustomizationRoll.cpp
ClassicBotListedGroupPlan.cpp
ClassicLfgRoleGap.cpp
ClassicDungeonFinderPlan.cpp
ClassicRaidConsumables.cpp
ClassicRaidDispel.cpp
ClassicRaidLoadout.cpp
ClassicBisPools.cpp
ClassicRaidFightScript.cpp
ClassicRaidGeometry.cpp
ClassicRaidRagnaros.cpp
ClassicRaidResistPotions.cpp
ClassicDrinkSay.cpp
ClassicReactionTiming.cpp
ClassicReactionWake.cpp
ClassicBotSize.cpp
ClassicPlacement.cpp
ClassicWorldPvp.cpp)
foreach(_test_source ${TESTS_MODULE_ONLY_SOURCES})
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/game/${_test_source} PROPERTIES HEADER_FILE_ONLY TRUE)
endforeach()
endif()
target_link_libraries(tests
PRIVATE
trinity-core-interface
game
Catch2::Catch2WithMain)
target_include_directories(tests
PRIVATE
${CMAKE_CURRENT_BINARY_DIR})
# game.lib calls into the Playerbot V2 module (PlayerbotHooks), so a build with the module needs it on the test link line too,
# exactly as worldserver does (src/server/worldserver/CMakeLists.txt).
if(BUILD_PLAYERBOT_V2)
target_compile_definitions(tests PRIVATE TESTS_HAVE_PLAYERBOT_V2)
target_link_libraries(tests PRIVATE playerbot-v2)
endif()
# game.lib uses extractor_common (Road corridors) when the tools are built; it reaches the test link line through game.
# Tests that use it directly (tests/tools) have their own executable below.
# Windows: the test executable loads libmysql/OpenSSL at start, and catch_discover_tests runs it (at ctest time, DISCOVERY_MODE PRE_TEST,
# so the list always matches the exe that is tested) to list the
# tests, so the directories those DLLs live in must be on PATH for the discovery and for the test run. The DLLs sit next to their
# import libraries (or in ../bin for OpenSSL) and, for a deployed build, in the install prefix.
set(TESTS_DL_PATHS)
if(WIN32)
set(_tests_dll_dirs ${CMAKE_INSTALL_PREFIX})
foreach(_lib ${MYSQL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY} ${OPENSSL_SSL_LIBRARY})
if(EXISTS "${_lib}")
get_filename_component(_dir "${_lib}" DIRECTORY)
list(APPEND _tests_dll_dirs "${_dir}" "${_dir}/../bin")
endif()
endforeach()
if(OPENSSL_ROOT_DIR)
list(APPEND _tests_dll_dirs "${OPENSSL_ROOT_DIR}/bin")
endif()
foreach(_dir ${_tests_dll_dirs})
if(IS_DIRECTORY "${_dir}")
get_filename_component(_dir "${_dir}" ABSOLUTE)
list(APPEND TESTS_DL_PATHS "${_dir}")
endif()
endforeach()
list(REMOVE_DUPLICATES TESTS_DL_PATHS)
endif()
if(TESTS_DL_PATHS)
catch_discover_tests(tests DISCOVERY_MODE PRE_TEST DL_PATHS ${TESTS_DL_PATHS})
else()
catch_discover_tests(tests DISCOVERY_MODE PRE_TEST)
endif()
set_target_properties(tests
PROPERTIES
FOLDER
"tests")
# Tools-layer tests live in their own executable so pre-existing breakage in
# tests/game/ doesn't block tooling tests from linking. They need extractor_common, so they exist only with -DTOOLS=1.
if(TARGET extractor_common)
add_subdirectory(tools)
else()
message(STATUS "tests: tools_tests skipped (TOOLS is off, no extractor_common)")
endif()
if(HEADLESS_TESTS)
add_subdirectory(headless)
endif()