Skip to content

Commit

Permalink
Runtime tests: fix creating tests in CMake build
Browse files Browse the repository at this point in the history
During CMake, all runtime test files are copied into the CMake build
directory using add_custom_command which issues 'cmake -E copy ...'.
For some reason, the last file in the tests/runtime directory
(tests/runtime/watchpoint) is never copied which causes two issues:
- the watchpoint tests are never run in CI,
- even if the local setup already has tests/runtime/watchpoint in the
  build directory (it seems to have been working in the past), it is
  never updated.

I'm not sure if this is caused by our change or a CMake update, however,
our approach is IMHO not correct as it makes the runtime_tests target
depend on the runtime tests files from the source directory. Changing it
to depend on the (newly copied) files from the build directory
eliminates the above issue.
  • Loading branch information
viktormalik committed May 10, 2024
1 parent 57af482 commit a2e86ff
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,15 @@ add_custom_target(
)
add_test(NAME runtime_tests COMMAND ./runtime-tests.sh)

file(GLOB_RECURSE runtime_test_files
file(GLOB_RECURSE runtime_test_src_files
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
CONFIGURE_DEPENDS
runtime/*
)
list(REMOVE_ITEM runtime_test_files runtime/engine/cmake_vars.py)
list(REMOVE_ITEM runtime_test_src_files runtime/engine/cmake_vars.py)

foreach(runtime_test_file ${runtime_test_files})
set(runtime_test_files)
foreach(runtime_test_file ${runtime_test_src_files})
add_custom_command(
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/${runtime_test_file}
Expand All @@ -140,6 +141,10 @@ foreach(runtime_test_file ${runtime_test_files})
DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/${runtime_test_file}
)
list(APPEND
runtime_test_files
${CMAKE_CURRENT_BINARY_DIR}/${runtime_test_file}
)
endforeach()
add_custom_target(runtime_test_files ALL DEPENDS ${runtime_test_files})
add_dependencies(runtime_tests runtime_test_files)
Expand Down

0 comments on commit a2e86ff

Please sign in to comment.