# win command within add\_test() never returns and blocks test suite execution

**URL:** https://discourse.cmake.org/t/win-command-within-add-test-never-returns-and-blocks-test-suite-execution/2545
**Category:** Usage
**Created:** [January 14, 2021, 4:02pm UTC](https://discourse.cmake.org/t/win-command-within-add-test-never-returns-and-blocks-test-suite-execution/2545 "2021-01-14T16:02:36Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![agouaillard](https://discourse.cmake.org/user_avatar/discourse.cmake.org/agouaillard/32/1086_2.png) [@agouaillard](https://discourse.cmake.org/u/agouaillard)
#### Post date: [January 14, 2021, 4:02pm UTC](https://discourse.cmake.org/t/win-command-within-add-test-never-returns-and-blocks-test-suite-execution/2545/1 "2021-01-14T16:02:36Z")

</div>

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 the corresponding test, even going through the indirection of a script, the script works on the command line but not in as COMMAND in a test. The tests launch the command but never returns.

doing my homework I found that add\_test() behavior with respect to shell and variables is align with execute\_process(). First naive usage of execute\_process() fails wit the same symptoms:

```auto
  set( my_CMD ${CMAKE_CURRENT_SOURCEDIR}/my_script.cmd )
  execute_process( COMMAND ${my_CMD} )

```

Then I found [#20917](https://gitlab.kitware.com/cmake/cmake/-/issues/20917) . redirecting the input, error, and output pipes, it finally works the way I want it to (should be binary dir here):

```auto
  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 in my case 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 when invoked on the command line in a CMD shell. I tried then to use that as a tes’ COMMAND but it is again not returning:

```auto
  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?
