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) 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) set(CMAKE_CXX_STANDARD 17)
option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF)
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)
option(ENABLE_TSAN "Enable the thread data race sanitizer" OFF) option(ENABLE_TSAN "Enable the thread data race sanitizer" OFF)
option(BUILD_STD "Build the BLT standard utilities." ON) option(BUILD_STD "Build the BLT standard utilities." ON)
option(BUILD_PROFILING "Build the BLT profiler extension" ON) option(BUILD_PROFILING "Build the BLT profiler extension" ON)
option(BUILD_NBT "Build the BLT NBT + eNBT extension" ON) option(BUILD_NBT "Build the BLT NBT + eNBT extension" ON)
option(BUILD_PARSE "Build the BLT parsers" ON) option(BUILD_PARSE "Build the BLT parsers" ON)
option(BUILD_TESTS "Build the BLT test set" OFF) 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_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_TRACE "Disable blt::logging BLT_TRACE macro" OFF)
option(BLT_DISABLE_DEBUG "Disable blt::logging BLT_DEBUG 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!") message("BLT ${CMAKE_PROJECT_VERSION} Successfully included!")
#if(${BUILD_TESTS}) if(${BUILD_TESTS})
# project(BLT_TESTS) message("Building test")
# project(BLT_TESTS VERSION ${BLT_TEST_VERSION})
# file(GLOB_RECURSE TESTS_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/tests/*.cpp")
# include_directories(tests/include)
# add_executable(BLT_TESTS ${TESTS_FILES})
# file(GLOB_RECURSE TEST_FILES "${CMAKE_CURRENT_SOURCE_DIR}/tests/src/*.cpp")
# target_link_libraries(BLT_TESTS PUBLIC BLT)
# message("Using files ${TEST_FILES}")
# if(MSVC)
# #target_compile_options(BLT_TESTS PRIVATE /W4) add_executable(BLT_TESTS ${TEST_FILES})
# if(${CMAKE_BUILD_TYPE} MATCHES Debug)
# target_link_options(BLT_TESTS PRIVATE /DEBUG) target_link_libraries(BLT_TESTS BLT)
# endif()
# else() target_compile_options(BLT_TESTS PRIVATE -Wall -Werror -Wpedantic -Wno-comment)
# target_compile_options(BLT_TESTS PRIVATE -Wall -Wextra -Wpedantic) target_link_options(BLT_TESTS PRIVATE -Wall -Werror -Wpedantic -Wno-comment)
# endif()
# if (${ENABLE_ADDRSAN} MATCHES ON)
# if (${ENABLE_ADDRSAN} MATCHES ON) target_compile_options(BLT_TESTS PRIVATE -fsanitize=address)
# target_compile_options(BLT_TESTS PRIVATE -fsanitize=address) target_link_options(BLT_TESTS PRIVATE -fsanitize=address)
# target_link_options(BLT_TESTS PRIVATE -fsanitize=address) endif ()
# endif ()
# if (${ENABLE_UBSAN} MATCHES ON)
# if (${ENABLE_UBSAN} MATCHES ON) target_compile_options(BLT_TESTS PRIVATE -fsanitize=undefined)
# target_compile_options(BLT_TESTS PRIVATE -fsanitize=undefined) target_link_options(BLT_TESTS PRIVATE -fsanitize=undefined)
# target_link_options(BLT_TESTS PRIVATE -fsanitize=undefined) endif ()
# endif ()
# if (${ENABLE_TSAN} MATCHES ON)
# if (${ENABLE_TSAN} MATCHES ON) target_compile_options(BLT_TESTS PRIVATE -fsanitize=thread)
# target_compile_options(BLT_TESTS PRIVATE -fsanitize=thread) target_link_options(BLT_TESTS PRIVATE -fsanitize=thread)
# target_link_options(BLT_TESTS PRIVATE -fsanitize=thread) endif ()
# endif () message("Built tests")
# endif()
# message("BLT tests included!")
#endif() project(BLT)

View File

@ -1,5 +1,6 @@
cmake_minimum_required(VERSION 3.1) cmake_minimum_required(VERSION 3.1)
project(BLT_TESTS) project(BLT_TESTS)
include(CTest)
option(ENABLE_ADDRSAN "Enable the address sanitizer" ON) option(ENABLE_ADDRSAN "Enable the address sanitizer" ON)
option(ENABLE_UBSAN "Enable the ub 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( parser.addArgument(
blt::arg_builder("--memory").setAction(blt::arg_action_t::STORE_TRUE).setNArgs(0).setHelp("Test the blt/std/memory.h file").build()); 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({"-c", "--no-color"}).setAction(blt::arg_action_t::STORE_TRUE).build());
parser.addArgument( parser.addArgument(
blt::arg_builder("--nbt") 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"); blt::logging::setLogOutputFormat("[${{TIME}}] [${{LOG_LEVEL}}] (${{FILE}}:${{LINE}}) ${{STR}}\n");
} }
if (args.contains("--memory"))
blt::test::memory::run();
if (args.contains("--nbt")) if (args.contains("--nbt"))
{ {
auto v = blt::arg_parse::get<std::string>(args["nbt"]); auto v = blt::arg_parse::get<std::string>(args["nbt"]);
@ -119,6 +115,8 @@ int main(int argc, const char** argv)
blt::tests::nbtWrite(); blt::tests::nbtWrite();
blt::tests::nbtRead(); blt::tests::nbtRead();
} }
runProfilingAndTableTests();
// //
// auto* funy = new class_func; // auto* funy = new class_func;