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 (cherry picked from commit 6a28ee7b2a4269aa7e43265d1cd0067537e3e883)
This commit is contained in:
1 parent
99a129d5bc
commit
831c45b1da
8 files changed
+83
-4
No files matched your search
+10
-2
@@ -23,7 +23,7 @@ jobs:
|
|||||||
command: |
|
command: |
|
||||||
mkdir bin
|
mkdir bin
|
||||||
cd bin
|
cd bin
|
||||||
cmake ../ -DWITH_WARNINGS=1 -DWITH_COREDEBUG=0 -DUSE_COREPCH=1 -DUSE_SCRIPTPCH=1 -DTOOLS=1 -DSCRIPTS=static -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=static -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 ..
|
cd ..
|
||||||
- run:
|
- run:
|
||||||
name: SQL checks
|
name: SQL checks
|
||||||
@@ -44,7 +44,15 @@ jobs:
|
|||||||
command: |
|
command: |
|
||||||
cd bin
|
cd bin
|
||||||
make -j 4 -k && make install
|
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
|
||||||
./bnetserver --version
|
./bnetserver --version
|
||||||
./worldserver --version
|
./worldserver --version
|
||||||
- setup_remote_docker:
|
- setup_remote_docker:
|
||||||
|
|||||||
+10
-2
@@ -8,8 +8,7 @@
|
|||||||
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
|
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
|
||||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
# We require CMake >= 3.2
|
cmake_minimum_required(VERSION 3.11)
|
||||||
cmake_minimum_required(VERSION 3.8)
|
|
||||||
|
|
||||||
# add this options before PROJECT keyword
|
# add this options before PROJECT keyword
|
||||||
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
|
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
|
||||||
@@ -91,3 +90,12 @@ add_subdirectory(dep)
|
|||||||
|
|
||||||
# add core sources
|
# add core sources
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
||||||
|
include(CTest)
|
||||||
|
if(BUILD_TESTING)
|
||||||
|
list(APPEND CMAKE_MODULE_PATH
|
||||||
|
"${Catch2_SOURCE_DIR}/contrib")
|
||||||
|
include(Catch)
|
||||||
|
|
||||||
|
add_subdirectory(tests)
|
||||||
|
endif()
|
||||||
@@ -50,4 +50,5 @@ option(WITH_COREDEBUG "Include additional debug-code in core"
|
|||||||
set(WITH_SOURCE_TREE "hierarchical" CACHE STRING "Build the source tree for IDE's.")
|
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)
|
set_property(CACHE WITH_SOURCE_TREE PROPERTY STRINGS no flat hierarchical hierarchical-folders)
|
||||||
option(WITHOUT_GIT "Disable the GIT testing routines" 0)
|
option(WITHOUT_GIT "Disable the GIT testing routines" 0)
|
||||||
|
option(BUILD_TESTING "Build test suite" 0)
|
||||||
|
|
||||||
@@ -35,6 +35,12 @@ else()
|
|||||||
message("* Build map/vmap tools : No")
|
message("* Build map/vmap tools : No")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(BUILD_TESTING)
|
||||||
|
message("* Build unit tests : Yes")
|
||||||
|
else()
|
||||||
|
message("* Build unit tests : No (default)")
|
||||||
|
endif()
|
||||||
|
|
||||||
if( USE_COREPCH )
|
if( USE_COREPCH )
|
||||||
message("* Build core w/PCH : Yes (default)")
|
message("* Build core w/PCH : Yes (default)")
|
||||||
else()
|
else()
|
||||||
|
|||||||
@@ -37,3 +37,12 @@ endif()
|
|||||||
if(TOOLS)
|
if(TOOLS)
|
||||||
add_subdirectory(StormLib)
|
add_subdirectory(StormLib)
|
||||||
endif()
|
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()
|
||||||
@@ -76,3 +76,7 @@ zmqpp (C++ binding for 0mq/zmq is a 'high-level' library that hides most of the
|
|||||||
rapidjson (A fast JSON parser/generator for C++ with both SAX/DOM style API http://rapidjson.org/)
|
rapidjson (A fast JSON parser/generator for C++ with both SAX/DOM style API http://rapidjson.org/)
|
||||||
https://github.com/miloyip/rapidjson
|
https://github.com/miloyip/rapidjson
|
||||||
Version: v1.1.0
|
Version: v1.1.0
|
||||||
|
|
||||||
|
catch2
|
||||||
|
https://github.com/catchorg/Catch2
|
||||||
|
Version: v2.13.0
|
||||||
@@ -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)
|
||||||
@@ -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