properly setup blt tests

v1
Brett 2023-11-22 23:25:29 -05:00
parent da0609e0fd
commit 6512da83e3
3 changed files with 49 additions and 43 deletions

View File

@ -1,16 +1,23 @@
cmake_minimum_required(VERSION 3.5)
project(BLT VERSION 0.8.1)
set(BLT_VERSION 0.8.1)
set(BLT_TEST_VERSION 0.0.1)
project(BLT VERSION ${BLT_VERSION})
set(CMAKE_CXX_STANDARD 17)
option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF)
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)
option(ENABLE_TSAN "Enable the thread data race sanitizer" OFF)
option(BUILD_STD "Build the BLT standard utilities." ON)
option(BUILD_PROFILING "Build the BLT profiler extension" ON)
option(BUILD_NBT "Build the BLT NBT + eNBT extension" ON)
option(BUILD_PARSE "Build the BLT parsers" ON)
option(BUILD_TESTS "Build the BLT test set" OFF)
option(BLT_DISABLE_LOGGING "Disable blt::logging (all macros and will safely disable logging function!)" OFF)
option(BLT_DISABLE_TRACE "Disable blt::logging BLT_TRACE macro" OFF)
option(BLT_DISABLE_DEBUG "Disable blt::logging BLT_DEBUG macro" OFF)
@ -93,38 +100,38 @@ endif()
message("BLT ${CMAKE_PROJECT_VERSION} Successfully included!")
#if(${BUILD_TESTS})
# project(BLT_TESTS)
#
# file(GLOB_RECURSE TESTS_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/tests/*.cpp")
#
# add_executable(BLT_TESTS ${TESTS_FILES})
#
# target_link_libraries(BLT_TESTS PUBLIC BLT)
#
# if(MSVC)
# #target_compile_options(BLT_TESTS PRIVATE /W4)
# if(${CMAKE_BUILD_TYPE} MATCHES Debug)
# target_link_options(BLT_TESTS PRIVATE /DEBUG)
# endif()
# else()
# target_compile_options(BLT_TESTS PRIVATE -Wall -Wextra -Wpedantic)
# endif()
#
# if (${ENABLE_ADDRSAN} MATCHES ON)
# target_compile_options(BLT_TESTS PRIVATE -fsanitize=address)
# target_link_options(BLT_TESTS PRIVATE -fsanitize=address)
# endif ()
#
# if (${ENABLE_UBSAN} MATCHES ON)
# target_compile_options(BLT_TESTS PRIVATE -fsanitize=undefined)
# target_link_options(BLT_TESTS PRIVATE -fsanitize=undefined)
# endif ()
#
# if (${ENABLE_TSAN} MATCHES ON)
# target_compile_options(BLT_TESTS PRIVATE -fsanitize=thread)
# target_link_options(BLT_TESTS PRIVATE -fsanitize=thread)
# endif ()
#
# message("BLT tests included!")
#endif()
if(${BUILD_TESTS})
message("Building test")
project(BLT_TESTS VERSION ${BLT_TEST_VERSION})
include_directories(tests/include)
file(GLOB_RECURSE TEST_FILES "${CMAKE_CURRENT_SOURCE_DIR}/tests/src/*.cpp")
message("Using files ${TEST_FILES}")
add_executable(BLT_TESTS ${TEST_FILES})
target_link_libraries(BLT_TESTS BLT)
target_compile_options(BLT_TESTS PRIVATE -Wall -Werror -Wpedantic -Wno-comment)
target_link_options(BLT_TESTS PRIVATE -Wall -Werror -Wpedantic -Wno-comment)
if (${ENABLE_ADDRSAN} MATCHES ON)
target_compile_options(BLT_TESTS PRIVATE -fsanitize=address)
target_link_options(BLT_TESTS PRIVATE -fsanitize=address)
endif ()
if (${ENABLE_UBSAN} MATCHES ON)
target_compile_options(BLT_TESTS PRIVATE -fsanitize=undefined)
target_link_options(BLT_TESTS PRIVATE -fsanitize=undefined)
endif ()
if (${ENABLE_TSAN} MATCHES ON)
target_compile_options(BLT_TESTS PRIVATE -fsanitize=thread)
target_link_options(BLT_TESTS PRIVATE -fsanitize=thread)
endif ()
message("Built tests")
endif()
project(BLT)

View File

@ -1,5 +1,6 @@
cmake_minimum_required(VERSION 3.1)
project(BLT_TESTS)
include(CTest)
option(ENABLE_ADDRSAN "Enable the address sanitizer" ON)
option(ENABLE_UBSAN "Enable the ub sanitizer" ON)

View File

@ -86,13 +86,6 @@ int main(int argc, const char** argv)
parser.addArgument(
blt::arg_builder("--memory").setAction(blt::arg_action_t::STORE_TRUE).setNArgs(0).setHelp("Test the blt/std/memory.h file").build());
auto args = parser.parse_args(argc, argv);
if (args.contains("--memory"))
blt::test::memory::run();
blt::arg_parse parser;
parser.addArgument(blt::arg_builder({"-c", "--no-color"}).setAction(blt::arg_action_t::STORE_TRUE).build());
parser.addArgument(
blt::arg_builder("--nbt")
@ -110,6 +103,9 @@ int main(int argc, const char** argv)
blt::logging::setLogOutputFormat("[${{TIME}}] [${{LOG_LEVEL}}] (${{FILE}}:${{LINE}}) ${{STR}}\n");
}
if (args.contains("--memory"))
blt::test::memory::run();
if (args.contains("--nbt"))
{
auto v = blt::arg_parse::get<std::string>(args["nbt"]);
@ -120,6 +116,8 @@ int main(int argc, const char** argv)
blt::tests::nbtRead();
}
runProfilingAndTableTests();
//
// auto* funy = new class_func;
// super_func* virtual_funy = new class_func;