feat/test: Add test harness #1
8 changed files with 76 additions and 0 deletions
|
|
@ -3,3 +3,5 @@ project(fishbowl)
|
||||||
|
|
||||||
add_subdirectory(engine)
|
add_subdirectory(engine)
|
||||||
add_subdirectory(client)
|
add_subdirectory(client)
|
||||||
|
|
||||||
|
enable_testing()
|
||||||
43
CMakePresets.json
Normal file
43
CMakePresets.json
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
{
|
||||||
|
"version": 10,
|
||||||
|
"cmakeMinimumRequired": {
|
||||||
|
"major": 3,
|
||||||
|
"minor": 11,
|
||||||
|
"patch": 0
|
||||||
|
},
|
||||||
|
"configurePresets": [
|
||||||
|
{
|
||||||
|
"name": "default",
|
||||||
|
"displayName": "Default",
|
||||||
|
"binaryDir": "build"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "default-with-tests",
|
||||||
|
"displayName": "Default (with tests)",
|
||||||
|
"inherits": "default",
|
||||||
|
"cacheVariables": {
|
||||||
|
"FISHBONE_BUILD_TESTS": "ON",
|
||||||
|
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"buildPresets": [
|
||||||
|
{
|
||||||
|
"name": "default",
|
||||||
|
"configurePreset": "default"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "default-with-tests",
|
||||||
|
"configurePreset": "default-with-tests"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"testPresets": [
|
||||||
|
{
|
||||||
|
"name": "default",
|
||||||
|
"configurePreset": "default-with-tests",
|
||||||
|
"output": {
|
||||||
|
"outputOnFailure": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
cmake_minimum_required(VERSION 3.11)
|
cmake_minimum_required(VERSION 3.11)
|
||||||
project(fishbone)
|
project(fishbone)
|
||||||
|
|
||||||
|
option(FISHBONE_BUILD_TESTS "Compile tests for fishbone" OFF)
|
||||||
|
|
||||||
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/CPM.cmake")
|
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/CPM.cmake")
|
||||||
message(STATUS "Downloading CPM.cmake...")
|
message(STATUS "Downloading CPM.cmake...")
|
||||||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
file(MAKE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||||
|
|
@ -56,3 +58,11 @@ fb_add_dep(fishbone lz4)
|
||||||
|
|
||||||
# Networking
|
# Networking
|
||||||
fb_add_dep(fishbone enet)
|
fb_add_dep(fishbone enet)
|
||||||
|
|
||||||
|
# Testing
|
||||||
|
if(FISHBONE_BUILD_TESTS)
|
||||||
|
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/deps/catch2.cmake")
|
||||||
|
list(APPEND CMAKE_MODULE_PATH ${Catch2_SOURCE_DIR}/extras)
|
||||||
|
enable_testing()
|
||||||
|
add_subdirectory(tests)
|
||||||
|
endif()
|
||||||
7
engine/cmake/deps/catch2.cmake
Normal file
7
engine/cmake/deps/catch2.cmake
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/CPM.cmake")
|
||||||
|
|
||||||
|
CPMAddPackage(
|
||||||
|
NAME "catch2"
|
||||||
|
GITHUB_REPOSITORY "catchorg/Catch2"
|
||||||
|
GIT_TAG "v3.15.0"
|
||||||
|
)
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <cstring>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include <fishbone/config.h>
|
#include <fishbone/config.h>
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,9 @@ namespace fishbone {
|
||||||
Mutex();
|
Mutex();
|
||||||
~Mutex();
|
~Mutex();
|
||||||
|
|
||||||
|
Mutex(const Mutex&) = delete;
|
||||||
|
Mutex& operator=(const Mutex&) = delete;
|
||||||
|
|
||||||
void lock();
|
void lock();
|
||||||
void unlock();
|
void unlock();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
9
engine/tests/CMakeLists.txt
Normal file
9
engine/tests/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
include (CTest)
|
||||||
|
include (Catch)
|
||||||
|
|
||||||
|
file(GLOB_RECURSE SRCS src/**.cc src/**.c)
|
||||||
|
|
||||||
|
add_executable(fishbone_test ${SRCS})
|
||||||
|
target_link_libraries(fishbone_test PRIVATE fishbone Catch2::Catch2WithMain)
|
||||||
|
target_include_directories(fishbone_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||||
|
catch_discover_tests(fishbone_test)
|
||||||
1
engine/tests/src/placeholder.cc
Normal file
1
engine/tests/src/placeholder.cc
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
#include <catch2/catch_test_macros.hpp>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue