Skip to content

Commit

Permalink
refactor: Delete non-compile tests (#4076)
Browse files Browse the repository at this point in the history
This seemed like a good idea at the time, but the complexity seems not
to be worth it.

--- END COMMIT MESSAGE ---

Any further description goes here, @-mentions are ok here!

- Use a *conventional commits* prefix: [quick
summary](https://www.conventionalcommits.org/en/v1.0.0/#summary)
- We mostly use `feat`, `fix`, `refactor`, `docs`, `chore` and `build`
types.
- A milestone will be assigned by one of the maintainers


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Tests**
- Removed legacy tests that verified compile-time constraints and
specific immutability checks.
- Added new unit tests for various components related to track
parameters and measurement helpers.

- **Chores**
- Streamlined the build process by eliminating outdated test-handling
logic.

These updates enhance test coverage and clean up internal testing
infrastructure without impacting end-user functionality.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
paulgessinger authored Feb 10, 2025
1 parent 3d74144 commit 0f4fc3e
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 207 deletions.

This file was deleted.

96 changes: 0 additions & 96 deletions Tests/UnitTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,102 +30,6 @@ macro(add_unittest _name _source)
add_dependencies(unit_tests ${_target})
endmacro()

# This function adds a non compile test. To this end it
# - Adds a target to process the file at `src`, and converts begin/end macros
# to `#if defined` in an extra file
# - Adds an executable target for that source file, excludes it from the default build
# Set a preprocessor define to enable ONE critical section.
# - Adds a test job to ctest which invokes CMake to build this executable target.
# The test is set to fail if the build succeeds, i.e. testing if something doesn't compile
# - Adds a closure test where it's supposed to actually compile if all of the
# critical sections are removed
function(add_non_compile_test name src)
# Don't add anything if the corresponding flag is not set
if(NOT ACTS_BUILD_NONCOMPILE_TESTS)
return()
endif()

# Figure out where to put the output file
cmake_path(ABSOLUTE_PATH src)
get_filename_component(_filename ${src} NAME)
set(_processed_source "${CMAKE_CURRENT_BINARY_DIR}/${_filename}")

# Add a build step to generate the source file by invoking a CMake script
add_custom_command(
OUTPUT ${_processed_source}
DEPENDS ${src}
COMMAND
"${CMAKE_COMMAND}" -DINPUT_FILE=${src}
-DOUTPUT_FILE=${_processed_source} -P
${CMAKE_SOURCE_DIR}/cmake/ActsGenerateNonCompileTest.cmake
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
add_custom_target("${name}_generated_source" DEPENDS ${_processed_source})

# Create the executable target, add the generated source code as a
# dependencies, so that it's generated when required.
set(test "ActsNonCompileTest${name}Closure")
set(target "${test}_Executable")
add_executable(${target} ${_processed_source})
target_link_libraries(${target} PUBLIC ActsCore ActsTestsCommonHelpers)
add_dependencies(${target} "${name}_generated_source")

# Don't build this target by default
set_target_properties(
${target}
PROPERTIES EXCLUDE_FROM_ALL ON EXCLUDE_FROM_DEFAULT_BUILD ON
)

# Add the test that calls into CMake to build the target. This one we expect to succeed
add_test(
NAME ${test}
COMMAND
${CMAKE_COMMAND} --build . --target ${target} --config
$<CONFIGURATION>
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)

# Loop over critical section markers and add one pair of executable targets and
# and test jobs. The test jobs are flipped, so success is failure.
file(READ ${src} content)
string(
REGEX MATCHALL
"ACTS_DOES_NOT_COMPILE_BEGIN\\(([A-Za-z0-9]+)\\)"
matches
${content}
)
foreach(match ${matches})
string(
REGEX REPLACE
"ACTS_DOES_NOT_COMPILE_BEGIN\\(([A-Za-z0-9]+)\\)"
"\\1"
match
${match}
)

set(test "ActsNonCompileTest${name}${match}")
set(target "${test}_Executable")
add_executable(${target} ${_processed_source})
target_link_libraries(${target} PUBLIC ActsCore ActsTestsCommonHelpers)
target_compile_definitions(${target} PRIVATE "-D${match}")
add_dependencies(${target} "${name}_generated_source")

set_target_properties(
${target}
PROPERTIES EXCLUDE_FROM_ALL ON EXCLUDE_FROM_DEFAULT_BUILD ON
)

add_test(
NAME ${test}
COMMAND
${CMAKE_COMMAND} --build . --target ${target} --config
$<CONFIGURATION>
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
set_tests_properties(${test} PROPERTIES WILL_FAIL ON)
endforeach()
endfunction()

add_subdirectory(Core)
add_subdirectory_if(Examples ACTS_BUILD_EXAMPLES AND ACTS_BUILD_EXAMPLES_UNITTESTS)
add_subdirectory_if(Benchmarks ACTS_BUILD_BENCHMARKS)
Expand Down
2 changes: 0 additions & 2 deletions Tests/UnitTests/Core/EventData/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,3 @@ add_unittest(SubspaceHelpers SubspaceHelpersTests.cpp)
add_unittest(SeedEdm SeedEdmTests.cpp)
add_unittest(SpacePointContainerEdm SpacePointContainerEdmTests.cpp)
add_unittest(TrackParameterHelpers TrackParameterHelpersTests.cpp)

add_non_compile_test(MultiTrajectory TrackContainerComplianceTests.cpp)
94 changes: 0 additions & 94 deletions Tests/UnitTests/Core/EventData/TrackContainerComplianceTests.cpp

This file was deleted.

0 comments on commit 0f4fc3e

Please sign in to comment.