# Unknown CMake command "get\_test\_property" in TEST\_INCLUDE\_FILES

**URL:** https://discourse.cmake.org/t/unknown-cmake-command-get-test-property-in-test-include-files/3828
**Category:** Code
**Created:** [July 24, 2021, 9:01pm UTC](https://discourse.cmake.org/t/unknown-cmake-command-get-test-property-in-test-include-files/3828 "2021-07-24T21:01:31Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Eric\_Pederson](https://discourse.cmake.org/user_avatar/discourse.cmake.org/eric_pederson/32/1641_2.png) [@Eric\_Pederson](https://discourse.cmake.org/u/Eric_Pederson)
#### Post date: [July 24, 2021, 9:01pm UTC](https://discourse.cmake.org/t/unknown-cmake-command-get-test-property-in-test-include-files/3828/1 "2021-07-24T21:01:31Z")

</div>

I helping the Catch2 team with CTest label support (see [Make catch tags work with ctest labels · Issue #1590 · catchorg/Catch2 · GitHub](https://github.com/catchorg/Catch2/issues/1590)).

The `catch_discover_tests` CMake command that comes with Catch2 uses the `TEST_INCLUDE_FILES` command to run custom code when ctest runs. Calling `get_test_property` in one of the `TEST_INCLUDE_FILES` fails with the error:

```auto
$ ctest --print-labels
Test project /home/eric/work/tw-base/cmake-build-debug
CMake Error at /home/eric/work/tw-base/cmake-build-debug/tw/utils/test/utils-test_tests-b858cb2.cmake:64 (get_test_property):
  Unknown CMake command "get_test_property".
Call Stack (most recent call first):
  /home/eric/work/tw-base/cmake-build-debug/tw/utils/test/utils-test_include-b858cb2.cmake:2 (include)
  /home/eric/work/tw-base/cmake-build-debug/tw/utils/test/CTestTestfile.cmake:7 (include)
  /home/eric/work/tw-base/cmake-build-debug/tw/utils/CTestTestfile.cmake:7 (subdirs)
  /home/eric/work/tw-base/cmake-build-debug/tw/CTestTestfile.cmake:8 (subdirs)
  CTestTestfile.cmake:7 (subdirs)

```

The `TEST_INCLUDE_FILES` code looks like:

```auto
add_test( [==[utils:Binary Encoding]==] /home/eric/work/tw-base/cmake-build-debug/bin/tw-base-utils-test [==[Binary Encoding]==])
set_tests_properties( [==[utils:Binary Encoding]==] PROPERTIES WORKING_DIRECTORY /home/eric/work/tw-base/cmake-build-debug/tw/utils/test)
get_test_property( [==[utils:Binary Encoding]==] LABELS test_labels)
set_tests_properties( [==[utils:Binary Encoding]==] PROPERTIES LABELS Binary Pack ${test_labels})

```

Is this expected?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [July 24, 2021, 11:48pm UTC](https://discourse.cmake.org/t/unknown-cmake-command-get-test-property-in-test-include-files/3828/2 "2021-07-24T23:48:17Z")

</div>

There is no `get_test_property` command. You should use `get_property(outvar TEST "${testname}")` instead.

---

<div class="post-metadata">

### Author: ![Eric\_Pederson](https://discourse.cmake.org/user_avatar/discourse.cmake.org/eric_pederson/32/1641_2.png) [@Eric\_Pederson](https://discourse.cmake.org/u/Eric_Pederson)
#### Post date: [July 25, 2021, 1:56am UTC](https://discourse.cmake.org/t/unknown-cmake-command-get-test-property-in-test-include-files/3828/3 "2021-07-25T01:56:16Z")

</div>

It’s in the docs? [https://cmake.org/cmake/help/latest/command/get\_test\_property.html](https://cmake.org/cmake/help/latest/command/get_test_property.html)

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [July 25, 2021, 3:25am UTC](https://discourse.cmake.org/t/unknown-cmake-command-get-test-property-in-test-include-files/3828/4 "2021-07-25T03:25:56Z")

</div>

Oh, so it is. Hmm.

Oh. I see now. You’re using `ctest`. The set of commands available in CTest scripts is not the same. This is one such command that is not available there.

---

<div class="post-metadata">

### Author: ![Eric\_Pederson](https://discourse.cmake.org/user_avatar/discourse.cmake.org/eric_pederson/32/1641_2.png) [@Eric\_Pederson](https://discourse.cmake.org/u/Eric_Pederson)
#### Post date: [July 25, 2021, 4:45am UTC](https://discourse.cmake.org/t/unknown-cmake-command-get-test-property-in-test-include-files/3828/5 "2021-07-25T04:45:21Z")

</div>

Interesting - is there a list of supported or unsupported commands in `TEST_INCLUDE_FILES`?

Another related issue - `set_property(TEST test APPEND PROPERTY LABELS labels)` fails in a `TEST_INCLUDE_FILES`. For example:

```auto
add_test( Testing /Users/eric/IdeaProjects/experiments-c/cmake-build-debug/bin/catch_example Testing)
set_tests_properties( Testing PROPERTIES WORKING_DIRECTORY /Users/eric/IdeaProjects/experiments-c/cmake-build-debug)
set_property(TEST Testing APPEND PROPERTY LABELS "example")

```

fails with

```auto
Test project /Users/eric/IdeaProjects/experiments-c/cmake-build-debug
CMake Error at /Users/eric/IdeaProjects/experiments-c/cmake-build-debug/catch_example_tests-b858cb2.cmake:9 (set_property):
  set_property given TEST names that do not exist:

    Testing

Call Stack (most recent call first):
  /Users/eric/IdeaProjects/experiments-c/cmake-build-debug/catch_example_include-b858cb2.cmake:2 (include)
  CTestTestfile.cmake:7 (include)

```

`get_property(TEST test APPEND PROPERTY LABELS var)` also fails in `TEST_INCLUDE_FILES`.

They both work fine in `CMakeLists.txt`.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [July 25, 2021, 12:48pm UTC](https://discourse.cmake.org/t/unknown-cmake-command-get-test-property-in-test-include-files/3828/6 "2021-07-25T12:48:25Z")

</div>

Hrm, yeah, I don’t see it documented anywhere ☹ . Let’s open [an issue](https://gitlab.kitware.com/cmake/cmake/-/issues) to get it documented.

@kyle.edwards You might know more since, IIRC, you added the “what commands are available where?” mechanisms to the code, but maybe that was just for CMake.

---

<div class="post-metadata">

### Author: ![Eric\_Pederson](https://discourse.cmake.org/user_avatar/discourse.cmake.org/eric_pederson/32/1641_2.png) [@Eric\_Pederson](https://discourse.cmake.org/u/Eric_Pederson)
#### Post date: [July 25, 2021, 3:38pm UTC](https://discourse.cmake.org/t/unknown-cmake-command-get-test-property-in-test-include-files/3828/7 "2021-07-25T15:38:34Z")

</div>

> [@ben.boeckel](#):
>
> Let’s open [an issue](https://gitlab.kitware.com/cmake/cmake/-/issues) to get it documented.

Done: [https://gitlab.kitware.com/cmake/cmake/-/issues/22473](https://gitlab.kitware.com/cmake/cmake/-/issues/22473)

Thanks Ben!

---

<div class="post-metadata">

### Author: ![AlexanderStein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alexanderstein/32/1559_2.png) [@AlexanderStein](https://discourse.cmake.org/u/AlexanderStein)
#### Post date: [July 27, 2021, 2:53pm UTC](https://discourse.cmake.org/t/unknown-cmake-command-get-test-property-in-test-include-files/3828/8 "2021-07-27T14:53:30Z")

</div>

I stumbled on the exact same problem. Until I noticed that apparently `ctest` only supports “Scripting Commands” (as what Craig Scott said in the issue).  
In my case I wanted to know the WORKING\_DIR from a `gtest_discover_tests` to support `Ninja Multi-Config`
