Skip to content

CTest: Add option to control error on no tests

Add a CTest argument that allows to consider no tests found not as error.

By default CTest will log an error message and return an error code if no tests were found. This option prevents CTest from considering this condition as error.

There are various reasons why someone wants to consider "no tests found" not as error. For example, if the number of tests depends on variables, plattform, test modes, you name it, there may be test configurations that simply does not contain any tests, in particular if the subproject feature is used and certain subprojects do not have any tests, while there are tests in other subprojects.

Currently CTest does return error code 255 in this case just like when any test failed. While this does not affect the reporting on CDash, scripts in the CI infrastructure (for example the CMake plugin in Jenkins) cannot distinguish between these cases making "ignore exit code 255" not an option to correctly report success or failure to tools like Jenkins.

This merge request is a minimal invasive change of CTest that is fully backwards compatible without changing any defaults. I wrote documentation and a test. If accepted, I am totally open for renaming the new option if --ignore-no-tests is considered a bad name.

Edited by Brad King

Merge request reports