Tests: add option to build one binary per GTest file

Bundling many tests in a single binary reduces build time and disk space
usage, but is less convenient for running individual tests command line
as filter flags need to be used.

This adds WITH_TESTS_SINGLE_BINARY to generate one executable file per
source file. Note that enabling this option requires a significant amount
of disk space.

Due to refactoring, the resulting ctest names are a bit different than
before. The number of tests is also a bit different depending if this
option is used, as one uses gtests discovery and the other is organized
purely by filename, which isn't always 1:1.

Co-authored-by: Sergey Sharybin <sergey@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/114604
This commit is contained in:
Brecht Van Lommel
2024-01-03 18:35:50 +01:00
committed by Brecht Van Lommel
parent 81017772f5
commit 364beee159
31 changed files with 330 additions and 181 deletions

View File

@@ -702,7 +702,7 @@ if(WITH_CYCLES OR WITH_GPU_RENDER_TESTS)
# Eevee
foreach(render_test ${render_tests})
add_render_test(
eevee_${render_test}_test
eevee_${render_test}
${CMAKE_CURRENT_LIST_DIR}/eevee_render_tests.py
-testdir "${TEST_SRC_DIR}/render/${render_test}"
-outdir "${TEST_OUT_DIR}/eevee"
@@ -712,7 +712,7 @@ if(WITH_CYCLES OR WITH_GPU_RENDER_TESTS)
# Eevee Next
foreach(render_test ${render_tests})
add_render_test(
eevee_next_${render_test}_test
eevee_next_${render_test}
${CMAKE_CURRENT_LIST_DIR}/eevee_next_render_tests.py
-testdir "${TEST_SRC_DIR}/render/${render_test}"
-outdir "${TEST_OUT_DIR}/eevee_next"
@@ -722,7 +722,7 @@ if(WITH_CYCLES OR WITH_GPU_RENDER_TESTS)
foreach(render_test ${render_tests})
# Workbench
add_render_test(
workbench_${render_test}_test
workbench_${render_test}
${CMAKE_CURRENT_LIST_DIR}/workbench_render_tests.py
-testdir "${TEST_SRC_DIR}/render/${render_test}"
-outdir "${TEST_OUT_DIR}/workbench"
@@ -733,7 +733,7 @@ if(WITH_CYCLES OR WITH_GPU_RENDER_TESTS)
# Hydra Storm
foreach(render_test ${render_tests})
add_render_test(
storm_hydra_${render_test}_test
storm_hydra_${render_test}
${CMAKE_CURRENT_LIST_DIR}/storm_render_tests.py
-testdir "${TEST_SRC_DIR}/render/${render_test}"
-outdir "${TEST_OUT_DIR}/storm_hydra"
@@ -743,7 +743,7 @@ if(WITH_CYCLES OR WITH_GPU_RENDER_TESTS)
foreach(render_test ${render_tests})
add_render_test(
storm_usd_${render_test}_test
storm_usd_${render_test}
${CMAKE_CURRENT_LIST_DIR}/storm_render_tests.py
-testdir "${TEST_SRC_DIR}/render/${render_test}"
-outdir "${TEST_OUT_DIR}/storm_usd"
@@ -776,7 +776,7 @@ if(WITH_COMPOSITOR_CPU)
foreach(comp_test ${compositor_tests})
add_render_test(
compositor_${comp_test}_cpu_test
compositor_${comp_test}_cpu
${CMAKE_CURRENT_LIST_DIR}/compositor_cpu_render_tests.py
-testdir "${TEST_SRC_DIR}/compositor/${comp_test}"
-outdir "${TEST_OUT_DIR}/compositor_cpu"
@@ -808,7 +808,7 @@ if(WITH_COMPOSITOR_REALTIME_TESTS AND WITH_COMPOSITOR_CPU)
foreach(comp_test ${compositor_tests})
add_render_test(
compositor_${comp_test}_realtime_test
compositor_${comp_test}_realtime
${CMAKE_CURRENT_LIST_DIR}/compositor_realtime_render_tests.py
-testdir "${TEST_SRC_DIR}/compositor/${comp_test}"
-outdir "${TEST_OUT_DIR}/compositor_realtime"
@@ -853,7 +853,7 @@ foreach(geo_node_test ${geo_node_tests})
foreach(file ${files})
get_filename_component(filename ${file} NAME_WE)
add_blender_test(
geo_node_${geo_node_test}_test_${filename}
geo_node_${geo_node_test}_${filename}
${file}
--python ${TEST_PYTHON_DIR}/geo_node_test.py
)
@@ -915,7 +915,7 @@ if(WITH_ALEMBIC)
get_filename_component(ALEMBIC_ROOT_DIR ${real_include_dir} DIRECTORY)
add_python_test(
bf_io_alembic_export_tests
io_alembic_export_tests
${CMAKE_CURRENT_LIST_DIR}/alembic_export_tests.py
--blender "${TEST_BLENDER_EXE}"
--testdir "${TEST_SRC_DIR}/alembic"
@@ -932,13 +932,13 @@ endif()
if(WITH_USD)
add_blender_test(
bf_io_usd_export_test
io_usd_export
--python ${CMAKE_CURRENT_LIST_DIR}/bl_usd_export_test.py
--
--testdir "${TEST_SRC_DIR}/usd"
)
add_blender_test(
bf_io_usd_import_test
io_usd_import
--python ${CMAKE_CURRENT_LIST_DIR}/bl_usd_import_test.py
--
--testdir "${TEST_SRC_DIR}/usd"
@@ -972,7 +972,7 @@ else()
endif()
add_blender_test(
bf_imbuf_save
imbuf_save
--python ${CMAKE_CURRENT_LIST_DIR}/bl_imbuf_save.py
--
-test_dir "${TEST_SRC_DIR}/imbuf_io"
@@ -982,7 +982,7 @@ else()
)
add_blender_test(
bf_imbuf_load
imbuf_load
--python ${CMAKE_CURRENT_LIST_DIR}/bl_imbuf_load.py
--
-test_dir "${TEST_SRC_DIR}/imbuf_io"
@@ -1038,7 +1038,7 @@ if(WITH_UI_TESTS)
)
foreach(ui_test ${_undo_tests})
add_blender_test_headless(
"bf_ui_${ui_test}"
"ui_${ui_test}"
--enable-event-simulate
--python "${CMAKE_CURRENT_LIST_DIR}/ui_simulate/run_blender_setup.py"
--