mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
dep: Add catch2 unit test framework and wire it up
To enable the test suite, make sure to configure CMake with -DBUILD_TESTING=1 , since it is disabled by default. The catch2 dependency will be downloaded during configure time. Also add a new target "tests-common", which includes unit tests for the "common" project. To finally run the tests use the "test" target. CircleCI: Run unit tests
This commit is contained in:
committed by
Peter Keresztes Schmidt
parent
3c0ac7302f
commit
6a28ee7b2a
@@ -23,7 +23,7 @@ jobs:
|
||||
command: |
|
||||
mkdir bin
|
||||
cd bin
|
||||
cmake ../ -DWITH_WARNINGS=1 -DWITH_COREDEBUG=0 -DUSE_COREPCH=1 -DUSE_SCRIPTPCH=1 -DTOOLS=1 -DSCRIPTS=dynamic -DSERVERS=1 -DNOJEM=0 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS="-Werror" -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_C_FLAGS_DEBUG="-DNDEBUG" -DCMAKE_CXX_FLAGS_DEBUG="-DNDEBUG" -DCMAKE_INSTALL_PREFIX=check_install
|
||||
cmake ../ -DWITH_WARNINGS=1 -DWITH_COREDEBUG=0 -DUSE_COREPCH=1 -DUSE_SCRIPTPCH=1 -DTOOLS=1 -DSCRIPTS=dynamic -DSERVERS=1 -DNOJEM=0 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS="-Werror" -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_C_FLAGS_DEBUG="-DNDEBUG" -DCMAKE_CXX_FLAGS_DEBUG="-DNDEBUG" -DCMAKE_INSTALL_PREFIX=check_install -DBUILD_TESTING=1
|
||||
cd ..
|
||||
- run:
|
||||
name: SQL checks
|
||||
@@ -42,7 +42,15 @@ jobs:
|
||||
command: |
|
||||
cd bin
|
||||
make -j 4 -k && make install
|
||||
cd check_install/bin
|
||||
- run:
|
||||
name: Unit tests
|
||||
command: |
|
||||
cd bin
|
||||
make test
|
||||
- run:
|
||||
name: Check executables
|
||||
command: |
|
||||
cd bin/check_install/bin
|
||||
./authserver --version
|
||||
./worldserver --version
|
||||
nopch:
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
cmake_minimum_required(VERSION 3.8)
|
||||
cmake_minimum_required(VERSION 3.11)
|
||||
|
||||
# add this options before PROJECT keyword
|
||||
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
|
||||
@@ -90,3 +90,12 @@ add_subdirectory(dep)
|
||||
|
||||
# add core sources
|
||||
add_subdirectory(src)
|
||||
|
||||
include(CTest)
|
||||
if(BUILD_TESTING)
|
||||
list(APPEND CMAKE_MODULE_PATH
|
||||
"${Catch2_SOURCE_DIR}/contrib")
|
||||
include(Catch)
|
||||
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
@@ -54,3 +54,4 @@ option(COPY_CONF "Copy authserver and worldserver .conf.dist files to the
|
||||
set(WITH_SOURCE_TREE "hierarchical" CACHE STRING "Build the source tree for IDE's.")
|
||||
set_property(CACHE WITH_SOURCE_TREE PROPERTY STRINGS no flat hierarchical hierarchical-folders)
|
||||
option(WITHOUT_GIT "Disable the GIT testing routines" 0)
|
||||
option(BUILD_TESTING "Build test suite" 0)
|
||||
|
||||
@@ -40,6 +40,12 @@ else()
|
||||
message("* Build map/vmap tools : No")
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTING)
|
||||
message("* Build unit tests : Yes")
|
||||
else()
|
||||
message("* Build unit tests : No (default)")
|
||||
endif()
|
||||
|
||||
if(USE_COREPCH)
|
||||
message("* Build core w/PCH : Yes (default)")
|
||||
else()
|
||||
|
||||
@@ -35,3 +35,12 @@ if(TOOLS)
|
||||
add_subdirectory(bzip2)
|
||||
add_subdirectory(libmpq)
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTING)
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(Catch2
|
||||
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
||||
GIT_TAG v2.13.0
|
||||
GIT_SHALLOW 1)
|
||||
FetchContent_MakeAvailable(Catch2)
|
||||
endif()
|
||||
|
||||
@@ -68,3 +68,7 @@ recastnavigation (Recast is state of the art navigation mesh construction toolse
|
||||
argon2
|
||||
https://github.com/P-H-C/phc-winner-argon2
|
||||
Version: 62358ba
|
||||
|
||||
catch2
|
||||
https://github.com/catchorg/Catch2
|
||||
Version: v2.13.0
|
||||
23
tests/CMakeLists.txt
Normal file
23
tests/CMakeLists.txt
Normal file
@@ -0,0 +1,23 @@
|
||||
# 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.
|
||||
|
||||
CollectSourceFiles(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/common
|
||||
COMMON_SOURCES
|
||||
)
|
||||
|
||||
add_executable(tests-common ${COMMON_SOURCES})
|
||||
|
||||
target_link_libraries(tests-common
|
||||
PRIVATE
|
||||
common
|
||||
Catch2::Catch2)
|
||||
|
||||
catch_discover_tests(tests-common)
|
||||
20
tests/common/test-main.cpp
Normal file
20
tests/common/test-main.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include "catch2/catch.hpp"
|
||||
Reference in New Issue
Block a user