1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 00:27:43 +00:00

Tests: Remove all file(GLOB) from CMakeLists in Tests

Using a file(GLOB) to find all the test files in a directory is an easy
hack to get things started, but has some drawbacks. Namely, if you add
a test, it won't be found again without re-running CMake. `ninja` seems
to do this automatically, but it would be nice to one day stop seeing it
rechecking our globbed directories.
This commit is contained in:
Andrew Kaster 2021-09-01 23:44:24 -06:00 committed by Andreas Kling
parent b5a145b466
commit 58797a1289
20 changed files with 154 additions and 73 deletions

View file

@ -70,6 +70,6 @@ set(AK_TEST_SOURCES
TestWeakPtr.cpp TestWeakPtr.cpp
) )
foreach(source ${AK_TEST_SOURCES}) foreach(source IN LISTS AK_TEST_SOURCES)
serenity_test(${source} AK) serenity_test("${source}" AK)
endforeach() endforeach()

View file

@ -1,18 +1,46 @@
file(GLOB CMD_SOURCES CONFIGURE_DEPENDS "*.cpp") set(TEST_SOURCES
file(GLOB LIBTEST_BASED_SOURCES "Test*.cpp") bind-local-socket-to-symlink.cpp
list(REMOVE_ITEM CMD_SOURCES ${LIBTEST_BASED_SOURCES}) bxvga-mmap-kernel-into-userspace.cpp
crash-fcntl-invalid-cmd.cpp
elf-execve-mmap-race.cpp
elf-symbolication-kernel-read-exploit.cpp
fuzz-syscalls.cpp
kill-pidtid-confusion.cpp
mmap-write-into-running-programs-executable-file.cpp
mprotect-multi-region-mprotect.cpp
munmap-multi-region-unmapping.cpp
nanosleep-race-outbuf-munmap.cpp
null-deref-close-during-select.cpp
null-deref-crash-during-pthread_join.cpp
path-resolution-race.cpp
pthread-cond-timedwait-example.cpp
setpgid-across-sessions-without-leader.cpp
stress-truncate.cpp
stress-writeread.cpp
uaf-close-while-blocked-in-read.cpp
unveil-symlinks.cpp
)
# FIXME: These tests do not use LibTest # FIXME: These tests do not use LibTest
foreach(CMD_SRC ${CMD_SOURCES}) foreach(source IN LISTS TEST_SOURCES)
get_filename_component(CMD_NAME ${CMD_SRC} NAME_WE) get_filename_component(test_name "${source}" NAME_WE)
add_executable(${CMD_NAME} ${CMD_SRC}) add_executable("${test_name}" "${source}")
target_link_libraries(${CMD_NAME} LibCore) target_link_libraries("${test_name}" LibCore)
install(TARGETS ${CMD_NAME} RUNTIME DESTINATION usr/Tests/Kernel/Legacy) install(TARGETS "${test_name}" RUNTIME DESTINATION usr/Tests/Kernel/Legacy)
endforeach() endforeach()
set(LIBTEST_BASED_SOURCES
TestEFault.cpp
TestKernelAlarm.cpp
TestKernelFilePermissions.cpp
TestKernelPledge.cpp
TestKernelUnveil.cpp
TestMunMap.cpp
TestProcFS.cpp
)
foreach(TEST_SRC ${LIBTEST_BASED_SOURCES}) foreach(libtest_source IN LISTS LIBTEST_BASED_SOURCES)
serenity_test(${TEST_SRC} Kernel) serenity_test("${libtest_source}" Kernel)
endforeach() endforeach()
target_link_libraries(elf-execve-mmap-race LibPthread) target_link_libraries(elf-execve-mmap-race LibPthread)

View file

@ -1,5 +1,9 @@
file(GLOB TEST_SOURCES CONFIGURE_DEPENDS "*.cpp") set(TEST_SOURCES
TestDeflate.cpp
TestGzip.cpp
TestZlib.cpp
)
foreach(source ${TEST_SOURCES}) foreach(source IN LISTS TEST_SOURCES)
serenity_test(${source} LibCompress LIBS LibCompress) serenity_test("${source}" LibCompress LIBS LibCompress)
endforeach() endforeach()

View file

@ -1,13 +1,12 @@
set( set(TEST_SOURCES
TEST_SOURCES TestLibCoreArgsParser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/TestLibCoreArgsParser.cpp TestLibCoreFileWatcher.cpp
${CMAKE_CURRENT_SOURCE_DIR}/TestLibCoreFileWatcher.cpp TestLibCoreIODevice.cpp
${CMAKE_CURRENT_SOURCE_DIR}/TestLibCoreIODevice.cpp TestLibCoreDeferredInvoke.cpp
${CMAKE_CURRENT_SOURCE_DIR}/TestLibCoreDeferredInvoke.cpp
) )
foreach(source ${TEST_SOURCES}) foreach(source IN LISTS TEST_SOURCES)
serenity_test(${source} LibCore) serenity_test("${source}" LibCore)
endforeach() endforeach()
install(FILES long_lines.txt DESTINATION usr/Tests/LibCore) install(FILES long_lines.txt DESTINATION usr/Tests/LibCore)

View file

@ -1,5 +1,8 @@
file(GLOB CMD_SOURCES CONFIGURE_DEPENDS "*.cpp") set(TEST_SOURCES
test-cpp-parser.cpp
test-cpp-preprocessor.cpp
)
foreach(CMD_SRC ${CMD_SOURCES}) foreach(source IN LISTS TEST_SOURCES)
serenity_test(${CMD_SRC} LibCpp LIBS LibCpp) serenity_test("${source}" LibCpp LIBS LibCpp)
endforeach() endforeach()

View file

@ -1,4 +1,12 @@
file(GLOB TEST_SOURCES CONFIGURE_DEPENDS "*.cpp") set(TEST_SOURCES
foreach(source ${TEST_SOURCES}) TestAES.cpp
serenity_test(${source} LibCrypto LIBS LibCrypto) TestBigInteger.cpp
TestChecksum.cpp
TestHash.cpp
TestHMAC.cpp
TestRSA.cpp
)
foreach(source IN LISTS TEST_SOURCES)
serenity_test("${source}" LibCrypto LIBS LibCrypto)
endforeach() endforeach()

View file

@ -1,5 +1,7 @@
file(GLOB CMD_SOURCES CONFIGURE_DEPENDS "*.cpp") set(TEST_SOURCES
test-elf.cpp
)
foreach(CMD_SRC ${CMD_SOURCES}) foreach(source IN LISTS TEST_SOURCES)
serenity_test(${CMD_SRC} LibELF) serenity_test("${source}" LibELF)
endforeach() endforeach()

View file

@ -1,5 +1,9 @@
file(GLOB TEST_SOURCES CONFIGURE_DEPENDS "*.cpp") set(TEST_SOURCES
BenchmarkGfxPainter.cpp
TestFontHandling.cpp
TestImageDecoder.cpp
)
foreach(source ${TEST_SOURCES}) foreach(source IN LISTS TEST_SOURCES)
serenity_test(${source} LibGfx LIBS LibGUI) serenity_test("${source}" LibGfx LIBS LibGUI)
endforeach() endforeach()

View file

@ -1,5 +1,7 @@
file(GLOB TEST_SOURCES CONFIGURE_DEPENDS "*.cpp") set(TEST_SOURCES
TestQuotedPrintable.cpp
)
foreach(source ${TEST_SOURCES}) foreach(source IN LISTS TEST_SOURCES)
serenity_test(${source} LibIMAP LIBS LibIMAP) serenity_test("${source}" LibIMAP LIBS LibIMAP)
endforeach() endforeach()

View file

@ -1,6 +1,8 @@
file(GLOB CMD_SOURCES CONFIGURE_DEPENDS "*.cpp") set(TEST_SOURCES
test-math.cpp
)
add_compile_options(-fno-builtin) add_compile_options(-fno-builtin)
foreach(CMD_SRC ${CMD_SOURCES}) foreach(source IN LISTS TEST_SOURCES)
serenity_test(${CMD_SRC} LibM) serenity_test("${source}" LibM)
endforeach() endforeach()

View file

@ -1,6 +1,9 @@
include(${SERENITY_PROJECT_ROOT}/Meta/CMake/commonmark_spec.cmake) include(${SERENITY_PROJECT_ROOT}/Meta/CMake/commonmark_spec.cmake)
file(GLOB TEST_SOURCES CONFIGURE_DEPENDS "*.cpp")
foreach(source ${TEST_SOURCES}) set(TEST_SOURCES
serenity_test(${source} LibMarkdown LIBS LibMarkdown) TestCommonmark.cpp
)
foreach(source IN LISTS TEST_SOURCES)
serenity_test("${source}" LibMarkdown LIBS LibMarkdown)
endforeach() endforeach()

View file

@ -1,4 +1,7 @@
file(GLOB TEST_SOURCES CONFIGURE_DEPENDS "*.cpp") set(TEST_SOURCES
foreach(source ${TEST_SOURCES}) TestLibPthreadSpinLocks.cpp
serenity_test(${source} LibPthread LIBS LibPthread) )
foreach(source IN LISTS TEST_SOURCES)
serenity_test("${source}" LibPthread LIBS LibPthread)
endforeach() endforeach()

View file

@ -1,5 +1,9 @@
file(GLOB TEST_SOURCES CONFIGURE_DEPENDS "*.cpp") set(TEST_SOURCES
Benchmark.cpp
Regex.cpp
RegexLibC.cpp
)
foreach(source ${TEST_SOURCES}) foreach(source IN LISTS TEST_SOURCES)
serenity_test(${source} LibRegex LIBS LibRegex) serenity_test("${source}" LibRegex LIBS LibRegex)
endforeach() endforeach()

View file

@ -1,5 +1,13 @@
file(GLOB TEST_SOURCES CONFIGURE_DEPENDS "*.cpp") set(TEST_SOURCES
TestSqlBtreeIndex.cpp
TestSqlDatabase.cpp
TestSqlExpressionParser.cpp
TestSqlHashIndex.cpp
TestSqlStatementExecution.cpp
TestSqlStatementParser.cpp
TestSqlValueAndTuple.cpp
)
foreach(source ${TEST_SOURCES}) foreach(source IN LISTS TEST_SOURCES)
serenity_test(${source} LibSQL LIBS LibSQL LibIPC) serenity_test("${source}" LibSQL LIBS LibSQL LibIPC)
endforeach() endforeach()

View file

@ -1,4 +1,7 @@
file(GLOB TEST_SOURCES CONFIGURE_DEPENDS "*.cpp") set(TEST_SOURCES
foreach(source ${TEST_SOURCES}) TestTLSHandshake.cpp
serenity_test(${source} LibTLS LIBS LibTLS LibCrypto) )
foreach(source IN LISTS TEST_SOURCES)
serenity_test("${source}" LibTLS LIBS LibTLS LibCrypto)
endforeach() endforeach()

View file

@ -1,4 +1,7 @@
file(GLOB TEST_SOURCES CONFIGURE_DEPENDS "*.cpp") set(TEST_SOURCES
foreach(source ${TEST_SOURCES}) TestThread.cpp
serenity_test(${source} LibThreading LIBS LibThreading LibPthread) )
foreach(source IN LISTS TEST_SOURCES)
serenity_test("${source}" LibThreading LIBS LibThreading LibPthread)
endforeach() endforeach()

View file

@ -1,5 +1,8 @@
file(GLOB TEST_SOURCES CONFIGURE_DEPENDS "*.cpp") set(TEST_SOURCES
TestUnicodeCharacterTypes.cpp
TestUnicodeLocale.cpp
)
foreach(source ${TEST_SOURCES}) foreach(source IN LISTS TEST_SOURCES)
serenity_test(${source} LibUnicode LIBS LibUnicode) serenity_test("${source}" LibUnicode LIBS LibUnicode)
endforeach() endforeach()

View file

@ -1,10 +1,9 @@
set( set(TEST_SOURCES
TEST_SOURCES TestHTMLTokenizer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/TestHTMLTokenizer.cpp
) )
foreach(source ${TEST_SOURCES}) foreach(source IN LISTS TEST_SOURCES)
serenity_test(${source} LibWeb LIBS LibWeb) serenity_test("${source}" LibWeb LIBS LibWeb)
endforeach() endforeach()
serenity_testjs_test(test-web.cpp test-web LIBS LibWeb) serenity_testjs_test(test-web.cpp test-web LIBS LibWeb)

View file

@ -1,9 +1,12 @@
file(GLOB CMD_SOURCES CONFIGURE_DEPENDS "*.cpp") set(TEST_SOURCES
test-run-ls.cpp
ue-write-oob.cpp
)
# FIXME: These tests do not use LibTest # FIXME: These tests do not use LibTest
foreach(CMD_SRC ${CMD_SOURCES}) foreach(source IN LISTS TEST_SOURCES)
get_filename_component(CMD_NAME ${CMD_SRC} NAME_WE) get_filename_component(test_name "${source}" NAME_WE)
add_executable(${CMD_NAME} ${CMD_SRC}) add_executable("${test_name}" "${source}")
target_link_libraries(${CMD_NAME} LibCore) target_link_libraries("${test_name}" LibCore)
install(TARGETS ${CMD_NAME} RUNTIME DESTINATION usr/Tests/UserEmulator) install(TARGETS "${test_name}" RUNTIME DESTINATION usr/Tests/UserEmulator)
endforeach() endforeach()