clean some test targets

This commit is contained in:
James Grogan 2023-03-23 19:07:31 +00:00
parent 198caa700b
commit 22c552b50f
5 changed files with 67 additions and 25 deletions

View file

@ -8,7 +8,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_COMPILE_WARNING_AS_ERROR ON) set(CMAKE_COMPILE_WARNING_AS_ERROR ON)
set_property( GLOBAL PROPERTY USE_FOLDERS ON) set_property( GLOBAL PROPERTY USE_FOLDERS ON)
set (CMAKE_MODULE_PATH infra/cmake) set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/infra/cmake)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

View file

@ -0,0 +1,38 @@
macro(unit_tests)
set(oneValueArgs MODULE_NAME)
set(multiValueArgs FILES DEPENDENCIES)
cmake_parse_arguments(UNIT_TESTS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
set(TARGET_NAME ${UNIT_TESTS_MODULE_NAME}_unit_tests)
add_executable(${TARGET_NAME} ${CMAKE_SOURCE_DIR}/test/test_runner.cpp ${UNIT_TESTS_FILES})
target_link_libraries(${TARGET_NAME} PUBLIC test_utils ${UNIT_TESTS_DEPENDENCIES})
set_property(TARGET ${TARGET_NAME} PROPERTY FOLDER test/${UNIT_TESTS_MODULE_NAME})
set(UNIT_TEST_TARGETS ${UNIT_TEST_TARGETS} ${TARGET_NAME} PARENT_SCOPE)
endmacro()
macro(integration_tests)
set(oneValueArgs MODULE_NAME)
set(multiValueArgs FILES FILES_UNIX FILES_WINDOWS DEPENDENCIES)
cmake_parse_arguments(UNIT_TESTS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
set(TARGET_NAME ${UNIT_TESTS_MODULE_NAME}_unit_tests)
set(PLATFORM_FILES)
if(UNIX)
list(APPEND PLATFORM_FILES ${UNIT_TESTS_UNIX_FILES}
elseif(WIN32)
list(APPEND PLATFORM_FILES ${UNIT_TESTS_WIN32_FILES}
endif()
add_executable(${TARGET_NAME} ${CMAKE_SOURCE_DIR}/test/test_runner.cpp
${UNIT_TESTS_FILES}
${PLATFORM_FILES}
)
target_link_libraries(${TARGET_NAME} PUBLIC test_utils ${UNIT_TESTS_DEPENDENCIES})
set_property(TARGET ${TARGET_NAME} PROPERTY FOLDER test/${UNIT_TESTS_MODULE_NAME})
set(UNIT_TEST_TARGETS ${UNIT_TEST_TARGETS} ${TARGET_NAME} PARENT_SCOPE)
endmacro()

View file

@ -1,5 +1,8 @@
add_subdirectory(test_utils) add_subdirectory(test_utils)
set(UNIT_TEST_TARGETS)
set(INTEGRATION_TEST_TARGETS)
add_subdirectory(core) add_subdirectory(core)
add_subdirectory(database) add_subdirectory(database)
add_subdirectory(fonts) add_subdirectory(fonts)
@ -47,3 +50,5 @@ add_executable(ui_tests WIN32 ui_test_runner.cpp ${UI_TEST_FILES})
target_link_libraries(ui_tests PUBLIC test_utils ${UI_TEST_DEPENDENCIES}) target_link_libraries(ui_tests PUBLIC test_utils ${UI_TEST_DEPENDENCIES})
set_property(TARGET ui_tests PROPERTY FOLDER test) set_property(TARGET ui_tests PROPERTY FOLDER test)
message(STATUS "Unit test targets: " ${UNIT_TEST_TARGETS})

View file

@ -1,21 +1,22 @@
set(MODULE_NAME audio) include(TestTargets)
set(UNIT_TESTS unit_tests(
${MODULE_NAME}/unit/TestAudioWriter.cpp MODULE_NAME audio
FILES
unit/TestAudioWriter.cpp
DEPENDENCIES
audio
) )
if(UNIX) integration_tests(
set(INTEGETATION_TESTS MODULE_NAME audio
${MODULE_NAME}/integration/TestAlsaInterface.cpp UNIX_FILES
integration/TestAlsaInterface.cpp
WINDOWS_FILES
integration/TestAlsaInterface.cpp
DEPENDENCIES
audio
) )
else()
set(INTEGETATION_TESTS
${MODULE_NAME}/integration/TestWasapiInterface.cpp
)
endif()
set(AUDIO_UNIT_TEST_FILES ${UNIT_TESTS} PARENT_SCOPE)
set(AUDIO_INTEGRATION_TEST_FILES ${INTEGETATION_TESTS} PARENT_SCOPE) set(AUDIO_INTEGRATION_TEST_FILES ${INTEGETATION_TESTS} PARENT_SCOPE)
set(AUDIO_UNIT_TEST_DEPENDENCIES ${MODULE_NAME} PARENT_SCOPE)
set(AUDIO_INTEGRATION_TEST_DEPENDENCIES ${MODULE_NAME} PARENT_SCOPE) set(AUDIO_INTEGRATION_TEST_DEPENDENCIES ${MODULE_NAME} PARENT_SCOPE)

View file

@ -1,15 +1,13 @@
set(MODULE_NAME core) include(TestTargets)
list(APPEND UNIT_TEST_FILES unit_tests(
MODULE_NAME core
FILES
TestByteUtils.cpp TestByteUtils.cpp
TestBitStream.cpp TestBitStream.cpp
TestDataStructures.cpp TestDataStructures.cpp
TestTomlReader.cpp TestTomlReader.cpp
TestStringUtils.cpp TestStringUtils.cpp
DEPENDENCIES
core
) )
set(UNIT_TEST_TARGET_NAME ${MODULE_NAME}_unit_tests)
add_executable(${UNIT_TEST_TARGET_NAME} ${CMAKE_SOURCE_DIR}/test/test_runner.cpp ${UNIT_TEST_FILES})
target_link_libraries(${UNIT_TEST_TARGET_NAME} PUBLIC test_utils core)
set_property(TARGET ${UNIT_TEST_TARGET_NAME} PROPERTY FOLDER test/${MODULE_NAME})