summaryrefslogtreecommitdiff
path: root/Meta
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2023-01-16 15:35:40 +0000
committerLinus Groh <mail@linusgroh.de>2023-01-19 11:50:10 +0000
commit5ac57f9d4198bbcfb35b2cb8bbca29889e9dec0d (patch)
treeac9ae25cac664990976f37be2e629c49b2152c25 /Meta
parent73350b8492465d757fe3a7699c0450aec41061b2 (diff)
downloadserenity-5ac57f9d4198bbcfb35b2cb8bbca29889e9dec0d.zip
Meta: Use existing test-sources lists for Lagom instead of globbing
...mostly. This creates and uses an override for the `serenity_test()` function, so that Lagom can make use of the existing `Tests/LibFoo/CMakeLists.txt` files instead of having to GLOB for test source files and manually copy any data files. Some GLOBs remain but this is most of them. Co-authored-by: Andrew Kaster <akaster@serenityos.org>
Diffstat (limited to 'Meta')
-rw-r--r--Meta/CMake/utils.cmake42
-rw-r--r--Meta/Lagom/CMakeLists.txt146
2 files changed, 52 insertions, 136 deletions
diff --git a/Meta/CMake/utils.cmake b/Meta/CMake/utils.cmake
index 6863783b22..336f7bc96d 100644
--- a/Meta/CMake/utils.cmake
+++ b/Meta/CMake/utils.cmake
@@ -107,26 +107,28 @@ if (NOT COMMAND serenity_bin)
endfunction()
endif()
-function(serenity_test test_src sub_dir)
- cmake_parse_arguments(PARSE_ARGV 2 SERENITY_TEST "MAIN_ALREADY_DEFINED" "CUSTOM_MAIN" "LIBS")
- set(TEST_SOURCES ${test_src})
- if ("${SERENITY_TEST_CUSTOM_MAIN}" STREQUAL "")
- set(SERENITY_TEST_CUSTOM_MAIN "$<TARGET_OBJECTS:LibTestMain>")
- endif()
- if (NOT ${SERENITY_TEST_MAIN_ALREADY_DEFINED})
- list(PREPEND TEST_SOURCES "${SERENITY_TEST_CUSTOM_MAIN}")
- endif()
- get_filename_component(test_name ${test_src} NAME_WE)
- add_executable(${test_name} ${TEST_SOURCES})
- add_dependencies(ComponentTests ${test_name})
- set_target_properties(${test_name} PROPERTIES EXCLUDE_FROM_ALL TRUE)
- serenity_set_implicit_links(${test_name})
- target_link_libraries(${test_name} PRIVATE LibTest LibCore)
- foreach(lib ${SERENITY_TEST_LIBS})
- target_link_libraries(${test_name} PRIVATE ${lib})
- endforeach()
- install(TARGETS ${test_name} RUNTIME DESTINATION usr/Tests/${sub_dir} OPTIONAL)
-endfunction()
+if (NOT COMMAND serenity_test)
+ function(serenity_test test_src sub_dir)
+ cmake_parse_arguments(PARSE_ARGV 2 SERENITY_TEST "MAIN_ALREADY_DEFINED" "CUSTOM_MAIN" "LIBS")
+ set(TEST_SOURCES ${test_src})
+ if ("${SERENITY_TEST_CUSTOM_MAIN}" STREQUAL "")
+ set(SERENITY_TEST_CUSTOM_MAIN "$<TARGET_OBJECTS:LibTestMain>")
+ endif()
+ if (NOT ${SERENITY_TEST_MAIN_ALREADY_DEFINED})
+ list(PREPEND TEST_SOURCES "${SERENITY_TEST_CUSTOM_MAIN}")
+ endif()
+ get_filename_component(test_name ${test_src} NAME_WE)
+ add_executable(${test_name} ${TEST_SOURCES})
+ add_dependencies(ComponentTests ${test_name})
+ set_target_properties(${test_name} PROPERTIES EXCLUDE_FROM_ALL TRUE)
+ serenity_set_implicit_links(${test_name})
+ target_link_libraries(${test_name} PRIVATE LibTest LibCore)
+ foreach(lib ${SERENITY_TEST_LIBS})
+ target_link_libraries(${test_name} PRIVATE ${lib})
+ endforeach()
+ install(TARGETS ${test_name} RUNTIME DESTINATION usr/Tests/${sub_dir} OPTIONAL)
+ endfunction()
+endif()
function(serenity_testjs_test test_src sub_dir)
cmake_parse_arguments(PARSE_ARGV 2 SERENITY_TEST "" "CUSTOM_MAIN" "LIBS")
diff --git a/Meta/Lagom/CMakeLists.txt b/Meta/Lagom/CMakeLists.txt
index 6e4b85fa03..b349f4ae36 100644
--- a/Meta/Lagom/CMakeLists.txt
+++ b/Meta/Lagom/CMakeLists.txt
@@ -259,6 +259,12 @@ function(lagom_test source)
)
endfunction()
+function(serenity_test test_src sub_dir)
+ cmake_parse_arguments(PARSE_ARGV 2 SERENITY_TEST "MAIN_ALREADY_DEFINED" "CUSTOM_MAIN" "LIBS")
+ # FIXME: Pass MAIN_ALREADY_DEFINED and CUSTOM_MAIN to support tests that use them.
+ lagom_test(${test_src} LIBS ${SERENITY_TEST_LIBS} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+endfunction()
+
function(serenity_bin name)
add_executable(${name} ${SOURCES} ${GENERATED_SOURCES})
add_executable(Lagom::${name} ALIAS ${name})
@@ -557,17 +563,29 @@ if (BUILD_LAGOM)
)
# LibTest tests from Tests/
- # AK
- file(GLOB AK_TEST_SOURCES CONFIGURE_DEPENDS "../../Tests/AK/*.cpp")
- foreach(source ${AK_TEST_SOURCES})
- lagom_test(${source} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../Tests/AK)
- endforeach()
- target_link_libraries(TestString PRIVATE LibUnicode)
+ set(TEST_DIRECTORIES
+ AK
+ LibAudio
+ LibCrypto
+ LibCompress
+ LibGL
+ LibLocale
+ LibMarkdown
+ LibPDF
+ LibSQL
+ LibTextCodec
+ LibTLS
+ LibTTF
+ LibTimeZone
+ LibUnicode
+ LibVideo
+ )
+ if (ENABLE_LAGOM_LIBWEB)
+ list(APPEND TEST_DIRECTORIES LibWeb)
+ endif()
- # LibAudio
- file(GLOB LIBAUDIO_TEST_SOURCES CONFIGURE_DEPENDS "../../Tests/LibAudio/*.cpp")
- foreach(source ${LIBAUDIO_TEST_SOURCES})
- lagom_test(${source} LIBS LibAudio WORKING_DIRECTORY ${FLAC_TEST_PATH})
+ foreach (dir IN LISTS TEST_DIRECTORIES)
+ add_serenity_subdirectory("Tests/${dir}")
endforeach()
# LibCore
@@ -577,104 +595,9 @@ if (BUILD_LAGOM)
lagom_test(../../Tests/LibCore/TestLibCoreFileWatcher.cpp)
endif()
- # Crypto
- file(GLOB LIBCRYPTO_TESTS CONFIGURE_DEPENDS "../../Tests/LibCrypto/*.cpp")
- foreach(source ${LIBCRYPTO_TESTS})
- lagom_test(${source} LIBS LibCrypto)
- endforeach()
-
- # Compress
- file(COPY "${SERENITY_PROJECT_ROOT}/Tests/LibCompress/brotli-test-files" DESTINATION "./")
- file(GLOB LIBCOMPRESS_TESTS CONFIGURE_DEPENDS "../../Tests/LibCompress/*.cpp")
- foreach(source ${LIBCOMPRESS_TESTS})
- lagom_test(${source} LIBS LibCompress)
- endforeach()
-
- # GL
- file(COPY "${SERENITY_PROJECT_ROOT}/Tests/LibGL/reference-images" DESTINATION "./")
- file(GLOB LIBGL_TESTS CONFIGURE_DEPENDS "../../Tests/LibGL/*.cpp")
- foreach(source ${LIBGL_TESTS})
- lagom_test(${source} LIBS LibGfx LibGL LibGPU LibSoftGPU)
- endforeach()
-
- # Locale
- file(GLOB LIBLOCALE_TEST_SOURCES CONFIGURE_DEPENDS "../../Tests/LibLocale/*.cpp")
- foreach(source ${LIBLOCALE_TEST_SOURCES})
- lagom_test(${source} LIBS LibLocale LibUnicode)
- endforeach()
-
- # PDF
- file(GLOB LIBPDF_TESTS CONFIGURE_DEPENDS "../../Tests/LibPDF/*.cpp")
- foreach(source ${LIBPDF_TESTS})
- lagom_test(${source} LIBS LibPDF WORKING_DIRECTORY ${SERENITY_PROJECT_ROOT}/Base/home/anon/Documents/pdf/)
- endforeach()
-
- # Regex
- file(GLOB LIBREGEX_TESTS CONFIGURE_DEPENDS "../../Tests/LibRegex/*.cpp")
# RegexLibC test POSIX <regex.h> and contains many Serenity extensions
- # It is therefore not reasonable to run it on Lagom
- list(REMOVE_ITEM LIBREGEX_TESTS "${CMAKE_CURRENT_SOURCE_DIR}/../../Tests/LibRegex/RegexLibC.cpp")
- foreach(source ${LIBREGEX_TESTS})
- lagom_test(${source} LIBS LibRegex)
- endforeach()
-
- # SQL
- file(GLOB LIBSQL_TEST_SOURCES CONFIGURE_DEPENDS "../../Tests/LibSQL/*.cpp")
- foreach(source ${LIBSQL_TEST_SOURCES})
- lagom_test(${source} LIBS LibSQL)
- endforeach()
-
- # TextCodec
- file(GLOB LIBTEXTCODEC_TESTS CONFIGURE_DEPENDS "../../Tests/LibTextCodec/*.cpp")
- foreach(source ${LIBTEXTCODEC_TESTS})
- lagom_test(${source} LIBS LibTextCodec
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../Tests/LibTextCodec)
- endforeach()
-
- # TLS
- file(GLOB LIBTLS_TESTS CONFIGURE_DEPENDS "../../Tests/LibTLS/*.cpp")
- foreach(source ${LIBTLS_TESTS})
- lagom_test(${source} LIBS LibCrypto LibTLS
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../Tests/LibTLS)
- endforeach()
-
- # TTF
- file(GLOB LIBTTF_TESTS CONFIGURE_DEPENDS "../../Tests/LibTTF/*.cpp")
- foreach(source ${LIBTTF_TESTS})
- lagom_test(${source} LIBS LibGfx)
- endforeach()
-
- # LibTimeZone
- file(GLOB LIBTIMEZONE_TEST_SOURCES CONFIGURE_DEPENDS "../../Tests/LibTimeZone/*.cpp")
- foreach(source ${LIBTIMEZONE_TEST_SOURCES})
- lagom_test(${source} LIBS LibTimeZone)
-
- get_filename_component(target "${source}" NAME_WLE)
- target_compile_definitions("${target}" PRIVATE ENABLE_TIME_ZONE_DATA=$<BOOL:${ENABLE_TIME_ZONE_DATABASE_DOWNLOAD}>)
- endforeach()
-
- # Unicode
- file(GLOB LIBUNICODE_TEST_SOURCES CONFIGURE_DEPENDS "../../Tests/LibUnicode/*.cpp")
- foreach(source ${LIBUNICODE_TEST_SOURCES})
- lagom_test(${source} LIBS LibUnicode)
- endforeach()
-
- # Video
- file(GLOB LIBVIDEO_TEST_SOURCES CONFIGURE_DEPENDS "../../Tests/LibVideo/*.cpp")
- foreach(source ${LIBVIDEO_TEST_SOURCES})
- lagom_test(${source} LIBS LibVideo
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../Tests/LibVideo)
- endforeach()
-
- # Web
- if (ENABLE_LAGOM_LIBWEB)
- file(COPY "${SERENITY_PROJECT_ROOT}/Tests/LibWeb/tokenizer-test.html" DESTINATION "./")
- file(GLOB LIBWEB_TEST_SOURCES CONFIGURE_DEPENDS "../../Tests/LibWeb/*.cpp")
- foreach(source ${LIBWEB_TEST_SOURCES})
- lagom_test(${source} LIBS LibWeb
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../Tests/LibWeb)
- endforeach()
- endif()
+ # It is therefore not reasonable to run it on Lagom, and we only run the Regex test
+ lagom_test(../../Tests/LibRegex/Regex.cpp LIBS LibRegex WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../Tests/LibRegex)
# JavaScriptTestRunner + LibTest tests
# test-js
@@ -704,15 +627,6 @@ if (BUILD_LAGOM)
)
set_tests_properties(Spreadsheet PROPERTIES ENVIRONMENT SERENITY_SOURCE_DIR=${SERENITY_PROJECT_ROOT})
-
- # Markdown
- include(commonmark_spec)
- file(GLOB LIBMARKDOWN_TEST_SOURCES CONFIGURE_DEPENDS "../../Tests/LibMarkdown/*.cpp")
- foreach(source ${LIBMARKDOWN_TEST_SOURCES})
- lagom_test(${source} LIBS LibMarkdown)
- endforeach()
- set_tests_properties(TestCommonmark PROPERTIES DISABLED YES)
-
# test-wasm
add_executable(test-wasm
../../Tests/LibWasm/test-wasm.cpp