mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-23 04:55:15 +00:00
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>
This commit is contained in:
parent
73350b8492
commit
5ac57f9d41
Notes:
sideshowbarker
2024-07-17 02:28:18 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/5ac57f9d41 Pull-request: https://github.com/SerenityOS/serenity/pull/17043 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/linusg Reviewed-by: https://github.com/nico
2 changed files with 52 additions and 136 deletions
|
@ -107,6 +107,7 @@ if (NOT COMMAND serenity_bin)
|
||||||
endfunction()
|
endfunction()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (NOT COMMAND serenity_test)
|
||||||
function(serenity_test test_src sub_dir)
|
function(serenity_test test_src sub_dir)
|
||||||
cmake_parse_arguments(PARSE_ARGV 2 SERENITY_TEST "MAIN_ALREADY_DEFINED" "CUSTOM_MAIN" "LIBS")
|
cmake_parse_arguments(PARSE_ARGV 2 SERENITY_TEST "MAIN_ALREADY_DEFINED" "CUSTOM_MAIN" "LIBS")
|
||||||
set(TEST_SOURCES ${test_src})
|
set(TEST_SOURCES ${test_src})
|
||||||
|
@ -127,6 +128,7 @@ function(serenity_test test_src sub_dir)
|
||||||
endforeach()
|
endforeach()
|
||||||
install(TARGETS ${test_name} RUNTIME DESTINATION usr/Tests/${sub_dir} OPTIONAL)
|
install(TARGETS ${test_name} RUNTIME DESTINATION usr/Tests/${sub_dir} OPTIONAL)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
endif()
|
||||||
|
|
||||||
function(serenity_testjs_test test_src sub_dir)
|
function(serenity_testjs_test test_src sub_dir)
|
||||||
cmake_parse_arguments(PARSE_ARGV 2 SERENITY_TEST "" "CUSTOM_MAIN" "LIBS")
|
cmake_parse_arguments(PARSE_ARGV 2 SERENITY_TEST "" "CUSTOM_MAIN" "LIBS")
|
||||||
|
|
|
@ -259,6 +259,12 @@ function(lagom_test source)
|
||||||
)
|
)
|
||||||
endfunction()
|
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)
|
function(serenity_bin name)
|
||||||
add_executable(${name} ${SOURCES} ${GENERATED_SOURCES})
|
add_executable(${name} ${SOURCES} ${GENERATED_SOURCES})
|
||||||
add_executable(Lagom::${name} ALIAS ${name})
|
add_executable(Lagom::${name} ALIAS ${name})
|
||||||
|
@ -557,17 +563,29 @@ if (BUILD_LAGOM)
|
||||||
)
|
)
|
||||||
|
|
||||||
# LibTest tests from Tests/
|
# LibTest tests from Tests/
|
||||||
# AK
|
set(TEST_DIRECTORIES
|
||||||
file(GLOB AK_TEST_SOURCES CONFIGURE_DEPENDS "../../Tests/AK/*.cpp")
|
AK
|
||||||
foreach(source ${AK_TEST_SOURCES})
|
LibAudio
|
||||||
lagom_test(${source} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../Tests/AK)
|
LibCrypto
|
||||||
endforeach()
|
LibCompress
|
||||||
target_link_libraries(TestString PRIVATE LibUnicode)
|
LibGL
|
||||||
|
LibLocale
|
||||||
|
LibMarkdown
|
||||||
|
LibPDF
|
||||||
|
LibSQL
|
||||||
|
LibTextCodec
|
||||||
|
LibTLS
|
||||||
|
LibTTF
|
||||||
|
LibTimeZone
|
||||||
|
LibUnicode
|
||||||
|
LibVideo
|
||||||
|
)
|
||||||
|
if (ENABLE_LAGOM_LIBWEB)
|
||||||
|
list(APPEND TEST_DIRECTORIES LibWeb)
|
||||||
|
endif()
|
||||||
|
|
||||||
# LibAudio
|
foreach (dir IN LISTS TEST_DIRECTORIES)
|
||||||
file(GLOB LIBAUDIO_TEST_SOURCES CONFIGURE_DEPENDS "../../Tests/LibAudio/*.cpp")
|
add_serenity_subdirectory("Tests/${dir}")
|
||||||
foreach(source ${LIBAUDIO_TEST_SOURCES})
|
|
||||||
lagom_test(${source} LIBS LibAudio WORKING_DIRECTORY ${FLAC_TEST_PATH})
|
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# LibCore
|
# LibCore
|
||||||
|
@ -577,104 +595,9 @@ if (BUILD_LAGOM)
|
||||||
lagom_test(../../Tests/LibCore/TestLibCoreFileWatcher.cpp)
|
lagom_test(../../Tests/LibCore/TestLibCoreFileWatcher.cpp)
|
||||||
endif()
|
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
|
# RegexLibC test POSIX <regex.h> and contains many Serenity extensions
|
||||||
# It is therefore not reasonable to run it on Lagom
|
# It is therefore not reasonable to run it on Lagom, and we only run the Regex test
|
||||||
list(REMOVE_ITEM LIBREGEX_TESTS "${CMAKE_CURRENT_SOURCE_DIR}/../../Tests/LibRegex/RegexLibC.cpp")
|
lagom_test(../../Tests/LibRegex/Regex.cpp LIBS LibRegex WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../Tests/LibRegex)
|
||||||
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()
|
|
||||||
|
|
||||||
# JavaScriptTestRunner + LibTest tests
|
# JavaScriptTestRunner + LibTest tests
|
||||||
# test-js
|
# test-js
|
||||||
|
@ -704,15 +627,6 @@ if (BUILD_LAGOM)
|
||||||
)
|
)
|
||||||
set_tests_properties(Spreadsheet PROPERTIES ENVIRONMENT SERENITY_SOURCE_DIR=${SERENITY_PROJECT_ROOT})
|
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
|
# test-wasm
|
||||||
add_executable(test-wasm
|
add_executable(test-wasm
|
||||||
../../Tests/LibWasm/test-wasm.cpp
|
../../Tests/LibWasm/test-wasm.cpp
|
||||||
|
|
Loading…
Add table
Reference in a new issue