3

I am currently using ctest to run tests written with the Catch framework. I would like to be able to filter which tests I run based on the internal Catch tags; for instance, I would like to be easily prevent any tests tagged [FUTURE] from running.

For a single test executable, ignoring ctest, this is straightforward:

myTestName '~[FUTURE]'

But I don't see any way to pass the '~[FUTURE]' argument to the Catch tests via ctest. This should be possible --test-command, but (1) --test-command doesn't seem to do anything without --build-and-test (which is not what I want) and (2) this apparently only works for one test at a time anyway, which is also not what I want (I just want to run ctest on my entire project).

I could just use ctest -N to get the names of the tests to run, then run the tests myself, but I don't know of any way to get the test filepath from ctest so I'd have to run find on all the test-names, and at that point I'm basically implementing my own test runner.

P.S. There are no existing tags for ctest or the Catch test framework, and I don't have the rep to create them. I'm not really sure what other tags would apply here. I'm only using the cmake tag because ctest is part of cmake.

  • 1
    Did you ever figure this out? – jorgeh Oct 19 '15 at 17:46
  • 1
    @jorgeh No, I did not. It does seem like a pretty glaring omission in ctest.... – Kyle Strand Oct 19 '15 at 17:48
  • I need something a little like this, so here's my current vague idea: you could declare each test to ctest twice, once with ~[FUTURE] as my-test-name and once without as my-test-name-future. Then you could filter them with a ctest regex. Alternatively you could add a ctest label to the future ones and use ctest's label filtering to run the right ones (might be a bit more robust than regexing the name). You could use a cmake wrapper function for test registration to make sure it was done consistently. – dshepherd Oct 17 '17 at 14:40

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.