# ctest does not show tests when executing in script mode

**URL:** https://discourse.cmake.org/t/ctest-does-not-show-tests-when-executing-in-script-mode/9860
**Category:** Usage
**Tags:** tool:ctest
**Created:** [January 15, 2024, 3:54pm UTC](https://discourse.cmake.org/t/ctest-does-not-show-tests-when-executing-in-script-mode/9860 "2024-01-15T15:54:09Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![pkiran](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/dc4da7/32.png) [@pkiran](https://discourse.cmake.org/u/pkiran)
#### Post date: [January 15, 2024, 3:54pm UTC](https://discourse.cmake.org/t/ctest-does-not-show-tests-when-executing-in-script-mode/9860/1 "2024-01-15T15:54:09Z")

</div>

Hi,

When using ctest like this:

```auto
ctest -S <script> -N

```

Always shows 0 tests selected. Any suggestion are appreciated. Please let me know if i am doing something wrong.  
Ctest version being used in 3.28.0

Thanks  
Best regards  
Phani

---

<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: [January 16, 2024, 1:18pm UTC](https://discourse.cmake.org/t/ctest-does-not-show-tests-when-executing-in-script-mode/9860/2 "2024-01-16T13:18:17Z")

</div>

I suspect that this is a hole in the handling of command line arguments and `ctest_test` arguments. If I had to guess, `-N` intercepts the list that `ctest_test` ends up consulting. The better option is probably to implement `ctest_test(PRINT_ONLY)` and to wire up `-N` to act as if that is specified to all `ctest_test` calls.

---

<div class="post-metadata">

### Author: ![pkiran](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/dc4da7/32.png) [@pkiran](https://discourse.cmake.org/u/pkiran)
#### Post date: [January 16, 2024, 1:30pm UTC](https://discourse.cmake.org/t/ctest-does-not-show-tests-when-executing-in-script-mode/9860/3 "2024-01-16T13:30:16Z")

</div>

Thanks for the reply. I would suggest `ctest_test(SHOW_ONLY)` to keep consistent with cmd line option name `--show-only`.

---

<div class="post-metadata">

### Author: ![pkiran](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/dc4da7/32.png) [@pkiran](https://discourse.cmake.org/u/pkiran)
#### Post date: [January 26, 2024, 8:51pm UTC](https://discourse.cmake.org/t/ctest-does-not-show-tests-when-executing-in-script-mode/9860/4 "2024-01-26T20:51:59Z")

</div>

Should I open an issue for this?

---

<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: [February 4, 2024, 1:35pm UTC](https://discourse.cmake.org/t/ctest-does-not-show-tests-when-executing-in-script-mode/9860/5 "2024-02-04T13:35:58Z")

</div>

That seems reasonable to me.

---

<div class="post-metadata">

### Author: ![pkiran](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/dc4da7/32.png) [@pkiran](https://discourse.cmake.org/u/pkiran)
#### Post date: [February 5, 2024, 8:56pm UTC](https://discourse.cmake.org/t/ctest-does-not-show-tests-when-executing-in-script-mode/9860/6 "2024-02-05T20:56:03Z")

</div>

Created at [https://gitlab.kitware.com/cmake/cmake/-/issues/25658](https://gitlab.kitware.com/cmake/cmake/-/issues/25658)
