Skip to content

Commit

Permalink
Tests to properly guard magic enum tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-rifkin committed Jun 1, 2024
1 parent c7726bd commit 69684ac
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 48 deletions.
4 changes: 0 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,6 @@ if(LIBASSERT_SANITIZER_BUILD)
add_link_options(-fsanitize=address)
endif()

if(LIBASSERT_BUILD_TESTING) # TODO: Maybe remove
# set(LIBASSERT_USE_MAGIC_ENUM ON)
endif()

# add pre-processor definitions corresponding to CMake options
# fixme: supposedly generator expressions should work for this
if(LIBASSERT_USE_MAGIC_ENUM)
Expand Down
90 changes: 46 additions & 44 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,60 +10,62 @@ if(PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
endif()
include(CTest)

# set(
# demo_sources
# tests/demo/bar.cpp
# tests/demo/baz/demo.cpp
# tests/demo/demo.cpp
# tests/demo/foo.cpp
# )
# add_executable(demo ${demo_sources})
# target_link_libraries(demo PRIVATE libassert-lib)
# target_compile_options(
# demo
# PRIVATE
# "-DLIBASSERT_USE_MAGIC_ENUM"
# "-DLIBASSERT_LOWERCASE"
# )
# target_compile_features(
# demo
# PUBLIC cxx_std_20
# )
# target_compile_definitions(
# demo
# PUBLIC LIBASSERT_SAFE_COMPARISONS
# )
add_executable(
demo
tests/demo/bar.cpp
tests/demo/baz/demo.cpp
tests/demo/demo.cpp
tests/demo/foo.cpp
)
target_link_libraries(demo PRIVATE libassert-lib)
target_compile_definitions(demo PRIVATE LIBASSERT_LOWERCASE)
if(NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 9.0))
target_compile_definitions(demo PRIVATE LIBASSERT_USE_MAGIC_ENUM)
endif()
target_compile_features(
demo
PUBLIC cxx_std_20
)
target_compile_definitions(
demo
PUBLIC LIBASSERT_SAFE_COMPARISONS
)

# add_executable(integration tests/integration/integration.cpp tests/integration/a.cpp tests/integration/x/a.cpp)
# # Temporary workaround for Visual Studio 2022 bug with __builtin_LINE() and __builtin_FILE()
# # https://developercommunity.visualstudio.com/t/__builtin_LINE-function-is-reporting-w/10439054?space=62&q=__builtin_function
# # TODO: Workaround in the header for end users?
# target_compile_features(integration PUBLIC cxx_std_20)
# target_link_libraries(integration PRIVATE libassert-lib)
# target_compile_options(
# integration
# PRIVATE
# "-DLIBASSERT_USE_MAGIC_ENUM"
# "-DLIBASSERT_LOWERCASE"
# "-DLIBASSERT_SAFE_COMPARISONS"
# )
# add_test(
# NAME integration
# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests
# COMMAND
# python3 run-tests.py $<TARGET_FILE:integration> ${CMAKE_BUILD_TYPE} ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_STANDARD}
# )
if(NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 9.0))
add_executable(integration tests/integration/integration.cpp tests/integration/a.cpp tests/integration/x/a.cpp)
# Temporary workaround for Visual Studio 2022 bug with __builtin_LINE() and __builtin_FILE()
# https://developercommunity.visualstudio.com/t/__builtin_LINE-function-is-reporting-w/10439054?space=62&q=__builtin_function
# TODO: Workaround in the header for end users?
target_compile_features(integration PUBLIC cxx_std_20)
target_link_libraries(integration PRIVATE libassert-lib)
target_compile_definitions(
integration
PRIVATE
LIBASSERT_USE_MAGIC_ENUM
LIBASSERT_LOWERCASE
LIBASSERT_SAFE_COMPARISONS
)
add_test(
NAME integration
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests
COMMAND
python3 run-tests.py $<TARGET_FILE:integration> ${CMAKE_BUILD_TYPE} ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_STANDARD}
)
set(integration_target integration)
else()
set(integration_target)
endif()

set(
dsym_targets
demo
# integration
${integration_target}
)

set(
all_targets
demo
# integration
${integration_target}
)

include(FetchContent)
Expand Down

0 comments on commit 69684ac

Please sign in to comment.