Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

CTest misparsing add_test calls

I am trying to run some tests using CTest.

My CTestTestFile.cmake contains a single test

add_test(NAME test1 
COMMAND python script.py args
)

but when I try run ctest it outputs the following

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Start 1: NAME
Could not find executable test1
Looked in the following places:
test1
test1.exe
Release/test1
Release/test1.exe
Debug/test1
Debug/test1.exe
MinSizeRel/test1
MinSizeRel/test1.exe
RelWithDebInfo/test1
RelWithDebInfo/test1.exe
Deployment/test1
Deployment/test1.exe
Development/test1
Development/test1.exe
Unable to find executable: test1
1/1 Test #1: NAME .............................***Not Run   0.00 sec

0% tests passed, 1 tests failed out of 1

Total Test time (real) =   0.14 sec

The following tests FAILED:
          1 - NAME (Not Run)

This suggests CTest thinks I’m using the short version of the command, so that my test’s name is NAME, the command is test1 and python script.py args are the arguments to the command, when this is of course not the case, as I’m obviously using the long version of the command.

I have CMake version 3.24.1 installed.

>Solution :

The CTest runtime, unlike CMake, accepts only the "basic" signature documented at the end of the usual add_test documentation:

add_test(<name> <command> [<arg>...])

Notice that CTest thought your test was named NAME.

So you have to write:

add_test(test1 "python" "script.py" "args")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading