infra: individual test executables

We used have tests contained in a single executable. This was fine for
testing, but it would be more convient to separate tests into indivudal
modules so targeted changes could have targeted tests.

This change associates each test file with its own executable. We now
have 14 tests for GSL each of which testing a different component.
This commit is contained in:
Carson Radtke
2025-08-21 09:57:18 -06:00
parent 7e0943d20d
commit e2dd4548c0
2 changed files with 28 additions and 22 deletions

View File

@@ -101,6 +101,7 @@ if(MSVC) # MSVC or simulating MSVC
-Wfloat-equal
-Wno-c++98-compat
-Wno-c++98-compat-pedantic
-Wno-reserved-identifier
-Wno-covered-switch-default # GTest
-Wno-deprecated-declarations # Allow tests for [[deprecated]] elements
-Wno-global-constructors # GTest
@@ -199,7 +200,8 @@ target_include_directories(gsl_tests_config SYSTEM INTERFACE
googletest/googletest/include
)
add_executable(gsl_tests
# Individually build and register each test source (except no_exception_ensure_tests.cpp)
set(GSL_TEST_SOURCES
algorithm_tests.cpp
assertion_tests.cpp
at_tests.cpp
@@ -212,16 +214,20 @@ add_executable(gsl_tests
span_ext_tests.cpp
span_tests.cpp
strict_notnull_tests.cpp
utils_tests.cpp
)
target_link_libraries(gsl_tests
foreach(src IN LISTS GSL_TEST_SOURCES)
get_filename_component(test_name "${src}" NAME_WE)
add_executable(${test_name} ${src})
target_link_libraries(${test_name}
Microsoft.GSL::GSL
gsl_tests_config
${GTestMain_LIBRARIES}
)
add_test(gsl_tests gsl_tests)
)
add_test(NAME ${test_name} COMMAND ${test_name})
set_target_properties(${test_name} PROPERTIES FOLDER "tests")
endforeach()
# No exception tests

View File

@@ -412,8 +412,8 @@ TEST(span_test, from_std_array_constructor)
static_assert(!CtorCompilesFor<span<int, 5>, std::array<int, 4>&>,
"!CtorCompilesFor<span<int, 5>, std::array<int, 4>&>");
#if !defined(_MSC_VER) || (_MSC_VER > 1943) || (__cplusplus >= 201703L)
// Fails on "Visual Studio 16 2019/Visual Studio 17 2022, windows-2019/2022, Debug/Release, 14".
#if !defined(_MSC_VER) || (__cplusplus >= 201703L)
// The following static assertion fails on MSVC in C++14 mode.
static_assert(!ConversionCompilesFor<span<int>, std::array<int, 4>>,
"!ConversionCompilesFor<span<int>, std::array<int, 4>>");
#endif
@@ -529,8 +529,8 @@ TEST(span_test, from_container_constructor)
EXPECT_TRUE(cs.data() == cstr.data());
}
#if !defined(_MSC_VER) || (_MSC_VER > 1943) || (__cplusplus >= 201703L)
// Fails on "Visual Studio 16 2019/Visual Studio 17 2022, windows-2019/2022, Debug/Release, 14".
#if !defined(_MSC_VER) || (__cplusplus >= 201703L)
// The following static assertion fails on MSVC in C++14 mode.
static_assert(!ConversionCompilesFor<span<int>, std::vector<int>>,
"!ConversionCompilesFor<span<int>, std::vector<int>>");
#endif // !defined(_MSC_VER) || (_MSC_VER > 1942) || (__cplusplus >= 201703L)