Skip to content

Commit

Permalink
build: populate env vars using "env"
Browse files Browse the repository at this point in the history
environmental variables cannot be populated to the tests if they are
performed as target using `cmake --build ... --target <target>`.
where the '<target>' is defined using `add_custom_target()`.

in order to populate the environmental variables down to the the COMMAND
specified by `add_custom_target()`, we need to launch the test using
`env`.

in this change, `cmake -E env` is used to launch the test command using
a more CMake native way without explicitly relying on yet another
external tool -- "env".

without this change, `Seastar_TEST_ENVIRONMENT` won't take effect when
running the tests.

Signed-off-by: Kefu Chai <[email protected]>
  • Loading branch information
tchaikov committed Feb 10, 2023
1 parent 58f1fd0 commit 2db2309
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions tests/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ function (seastar_add_test name)
OUTPUT_NAME ${name}_test)

add_dependencies (unit_tests ${executable_target})
set (forwarded_args COMMAND ${executable_target} ${args})
set (forwarded_args COMMAND ${CMAKE_COMMAND} -E env "${Seastar_TEST_ENVIRONMENT}" $<TARGET_FILE:${executable_target}> ${args})
else ()
if (NOT (parsed_args_KIND STREQUAL "CUSTOM"))
message (FATAL_ERROR "SOURCES are required for ${parsed_args_KIND} tests")
endif ()

set (forwarded_args COMMAND ${parsed_args_RUN_ARGS})
set (forwarded_args COMMAND ${CMAKE_COMMAND} -E env "${Seastar_TEST_ENVIRONMENT}" ${parsed_args_RUN_ARGS})
endif ()

#
Expand All @@ -175,8 +175,7 @@ function (seastar_add_test name)

set_tests_properties (Seastar.unit.${name}
PROPERTIES
TIMEOUT ${Seastar_TEST_TIMEOUT}
ENVIRONMENT "${Seastar_TEST_ENVIRONMENT}")
TIMEOUT ${Seastar_TEST_TIMEOUT})
endfunction ()

#
Expand Down

0 comments on commit 2db2309

Please sign in to comment.