# CTEST\_CUSTOM\_TESTS\_IGNORE doesn't use regex like docs suggest?

**URL:** https://discourse.cmake.org/t/ctest-custom-tests-ignore-doesnt-use-regex-like-docs-suggest/4267
**Category:** Usage
**Created:** [October 13, 2021, 2:47pm UTC](https://discourse.cmake.org/t/ctest-custom-tests-ignore-doesnt-use-regex-like-docs-suggest/4267 "2021-10-13T14:47:30Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![JonTheBurger](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jontheburger/32/1873_2.png) [@JonTheBurger](https://discourse.cmake.org/u/JonTheBurger)
#### Post date: [October 13, 2021, 2:47pm UTC](https://discourse.cmake.org/t/ctest-custom-tests-ignore-doesnt-use-regex-like-docs-suggest/4267/1 "2021-10-13T14:47:30Z")

</div>

I think there’s a documentation bug for `CTEST_CUSTOM_TESTS_IGNORE`. The [documentation](https://cmake.org/cmake/help/latest/variable/CTEST_CUSTOM_TESTS_IGNORE.html) says it uses regular expressions, but this does not seem to be the case.

```auto
ctest -N
Test project /home/vagrant/Projects/cxxscratch/build/GCC-Debug
  Test #1: CxxMain
  Test #2: CxxMain.memcheck
  Test #3: CMain

Total Tests: 3

```

When I create a `${CMAKE_BINARY_DIR}/CTestCustom.cmake` with the following content

```auto
set(CTEST_CUSTOM_TESTS_IGNORE
  ".*CxxMain.*"
)

```

and run `cmake --build . --target test`, the `CxxMain` tests are still executed

```auto
cmake --build . --target test
[0/1] Running tests...
Test project /home/vagrant/Documents/cxxscratch/build/GCC-Debug
    Start 1: CxxMain
1/3 Test #1: CxxMain .......................... Passed 0.00 sec
    Start 2: CxxMain.memcheck
2/3 Test #2: CxxMain.memcheck ................. Passed 0.01 sec
    Start 3: CMain
3/3 Test #3: CMain ............................ Passed 0.00 sec

100% tests passed, 0 tests failed out of 3

Total Test time (real) = 0.02 sec

```

It doesn’t seem to accept GLOBs either. It does work if you match the test names explicitly. I personally would gladly welcome a change to use regex, but the docs at least should maybe be updated. Thanks!

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [October 13, 2021, 8:56pm UTC](https://discourse.cmake.org/t/ctest-custom-tests-ignore-doesnt-use-regex-like-docs-suggest/4267/2 "2021-10-13T20:56:44Z")

</div>

I took a very quick look at the source code and you are correct. It just does a simple string comparison, it doesn’t treat it as a regular expression. Could you please [report](https://gitlab.kitware.com/cmake/cmake/-/issues/new) this issue in the issue tracker? In the first instance, the docs should be updated. As for actually making this support regular expressions, that might be tricky because of the need to preserve backward compatible behavior.

---

<div class="post-metadata">

### Author: ![JonTheBurger](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jontheburger/32/1873_2.png) [@JonTheBurger](https://discourse.cmake.org/u/JonTheBurger)
#### Post date: [October 13, 2021, 9:55pm UTC](https://discourse.cmake.org/t/ctest-custom-tests-ignore-doesnt-use-regex-like-docs-suggest/4267/3 "2021-10-13T21:55:41Z")

</div>

Thanks Craig!

I added a bug ticket here:  
[https://gitlab.kitware.com/cmake/cmake/-/issues/22758](https://gitlab.kitware.com/cmake/cmake/-/issues/22758)

Let me know if I should do anything else.  
Thanks!

P.S. love the book by the way 🙂

---

<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: [October 15, 2021, 11:42pm UTC](https://discourse.cmake.org/t/ctest-custom-tests-ignore-doesnt-use-regex-like-docs-suggest/4267/4 "2021-10-15T23:42:51Z")

</div>

> [@craig.scott](#):
>
> As for actually making this support regular expressions, that might be tricky because of the need to preserve backward compatible behavior.

A new variable name should suffice (`CTEST_CUSTOM_TESTS_IGNORE_REGEX`).
