Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
CMake
CMake
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,198
    • Issues 3,198
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 16
    • Merge Requests 16
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • External Wiki
    • External Wiki
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • CMake
  • CMakeCMake
  • Issues
  • #21704

Closed
Open
Opened Jan 13, 2021 by Alexandre GOUAILLARD@agouaillard

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?

To upload designs, you'll need to enable LFS and have admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: cmake/cmake#21704