# ctest with LABELS to classify tests

**URL:** https://discourse.cmake.org/t/ctest-with-labels-to-classify-tests/2375
**Category:** Code
**Created:** [December 15, 2020, 12:19pm UTC](https://discourse.cmake.org/t/ctest-with-labels-to-classify-tests/2375 "2020-12-15T12:19:35Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![jverdicchio](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/j/3da27b/32.png) [@jverdicchio](https://discourse.cmake.org/u/jverdicchio)
#### Post date: [December 15, 2020, 12:19pm UTC](https://discourse.cmake.org/t/ctest-with-labels-to-classify-tests/2375/1 "2020-12-15T12:19:35Z")

</div>

In my software group we have a test suite that is controlled and run using bash scripts.  
I’m proposing using CTest and some python to replace these scripts. The test suite contains around 50 cases but we are planning on expanding this list to encompass a larger variety of cases.  
At a previous employer I believe we used CTest with LABELS to be able to control which tests were being run. For instance BASIC,LARGE\_TESTS, PERIODIC\_MESH, BOUNDARY\_LAYERS .

I can’t remember the syntax to set these labels up within the CMake framework and the documentation regarding LABELS or any other type of classification is brief.

Ideally, I want for each test (CMakeLists.txt file) have a line something like  
**add\_test(NAME ${TESTNAME} COMMAND runATest.py ${STAR\_HOME} ${TESTNAME} )**  
**set(LABELS BASIC BOUNDARY\_LAYERS)**

and then I can run  
**ctest -L BASIC -L PERIODIC\_MESH**  
and only the tests with the appropriate labels are run.

Are LABELS the appropriate tool to be using here? If so, what is the syntax to set this up? Can ctest deal with multiple labels as I would like?

If LABELS are not appropriate, what should I be using?

---

<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: [December 15, 2020, 4:14pm UTC](https://discourse.cmake.org/t/ctest-with-labels-to-classify-tests/2375/2 "2020-12-15T16:14:51Z")

</div>

`LABELS` is documented as a “test property”. These are manipulated either via `set_tests_properties` or `set_property`:

```cmake
set_property(TEST test1 test2 APPEND
  PROPERTY LABELS label1 label2)

```
