# ctest "-I" does not behave as advertised in "Mastering CMake » Testing With CMake and CTest » Testing Using CTest"

**URL:** https://discourse.cmake.org/t/ctest-i-does-not-behave-as-advertised-in-mastering-cmake-testing-with-cmake-and-ctest-testing-using-ctest/8682
**Category:** Usage
**Tags:** os:linux
**Created:** [August 5, 2023, 4:37pm UTC](https://discourse.cmake.org/t/ctest-i-does-not-behave-as-advertised-in-mastering-cmake-testing-with-cmake-and-ctest-testing-using-ctest/8682 "2023-08-05T16:37:42Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![davidp](https://discourse.cmake.org/user_avatar/discourse.cmake.org/davidp/32/3678_2.png) [@davidp](https://discourse.cmake.org/u/davidp)
#### Post date: [August 5, 2023, 4:37pm UTC](https://discourse.cmake.org/t/ctest-i-does-not-behave-as-advertised-in-mastering-cmake-testing-with-cmake-and-ctest-testing-using-ctest/8682/1 "2023-08-05T16:37:42Z")

</div>

This post is provided as an informative one rather than a plea for help.

I’ve successfully built my project using CMake; however, the CTest command line does behave as advertised when using the `-I` option (reference: [Mastering CMake » Testing With CMake and CTest » Testing Using CTest](https://cmake.org/cmake/help/book/mastering-cmake/chapter/Testing%20With%20CMake%20and%20CTest.html#testing-using-ctest)). The `-I` option is intriguing for selective test execution, and it is documented as follows:

```auto
-I [Start,End,Stride,test#,test#|Test file]
                      Run specific tests by range and number.

```

Specifically, the following fails to limit execution to tests 12 and 21 in my suite:

```auto
ctest -j`corecount` --output-on-failure -I ,,,12,21

```

The following successfully executes the specific tests for CTest 3.26.3:

```auto
ctest -j`corecount` --output-on-failure -I 0,0,0,12,21

```

Neither of the commands listed above work for CTest 3.20.2.

These sort of behavioral and documentation inconsistencies provide a painful user experience. What is a humble(?) developer to do?

**SOLUTION?**

So far, the following command syntax resolves these behavioral discrepancies for varied versions of CTest:

```auto
ctest -j`corecount` --output-on-failure -I 0,0,1,12,21

```

It seems the Stride parameter is required to be non-zero and the Start,End values must not be blank for consistency when one wants to limit test execution to specific test numbers. It’s unfortunate that the so-called “CMake bible” does not clarify such nuance.

**EDIT**

One final comment to add to this post. The `-LE` option is incompatible with the `-I` option. Using them simultaneously may not execute the desired tests pecified by the `-I` option.

---

<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: [August 7, 2023, 11:28am UTC](https://discourse.cmake.org/t/ctest-i-does-not-behave-as-advertised-in-mastering-cmake-testing-with-cmake-and-ctest-testing-using-ctest/8682/2 "2023-08-07T11:28:34Z")

</div>

@bill.hoffman What’s our process for updating “Mastering CMake”?

---

<div class="post-metadata">

### Author: ![bill.hoffman](https://discourse.cmake.org/user_avatar/discourse.cmake.org/bill.hoffman/32/13_2.png) [@bill.hoffman](https://discourse.cmake.org/u/bill.hoffman)
#### Post date: [October 11, 2023, 7:47pm UTC](https://discourse.cmake.org/t/ctest-i-does-not-behave-as-advertised-in-mastering-cmake-testing-with-cmake-and-ctest-testing-using-ctest/8682/3 "2023-10-11T19:47:55Z")

</div>

It is open source now, so an MR would be the way to make changes.

---

<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 11, 2023, 9:35pm UTC](https://discourse.cmake.org/t/ctest-i-does-not-behave-as-advertised-in-mastering-cmake-testing-with-cmake-and-ctest-testing-using-ctest/8682/4 "2023-10-11T21:35:54Z")

</div>

For completion’s sake, the repo is here: [https://gitlab.kitware.com/cmake/mastering-cmake](https://gitlab.kitware.com/cmake/mastering-cmake)
