command within add_test never returns
I have a simple command on windows that starts an appium server on a separate windows and return:
start appium
when I try to add a test, even going through the indirection of a script, the script works on the command line but not in as a test. The tests never return.
doing my homework I found that add_test behavior with respect to shell and variables is align with execute_process(). First naive approach fails the same way:
set( my_CMD ${CMAKE_CURRENT_SOURCEDIR}/my_script.cmd )
execute_process( COMMAND ${my_CMD} )
Then I found #20917 . redirecting the pipes, it finally works the way I want it to (should be binary dir here):
execute_process(
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_SOURCE_DIR}/dev.null
)
set( my_CMD ${CMAKE_CURRENT_SOURCEDIR}/my_script.cmd )
execute_process(
COMMAND ${my_CMD}
INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/dev.null
OUTPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/dev.null
ERROR_FILE ${CMAKE_CURRENT_SOURCE_DIR}/dev.null
RESULT_VARIABLE RESULT
)
Unfortunately, the add_test()
API does not have those options ..., and I cannot do this at configuration time
I extracted the execute_process()
logic into a cmake script, and then used cmake -P
and it was working.
I tried then to use that inside a test but it is again not returning:
cmake_minimum_required(VERSION 3.18)
project(myTest)
include(CTEST)
add_test(
NAME start_appium
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/start_appium.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
At this stage, it's getting so convoluted that I must be missing something obvious.
What did I miss?