[CMake] Can't run units test defined in subdirectories

Tron Thomas tron.thomas at verizon.net
Fri Nov 28 11:07:37 EST 2008


Okay, I changed the add_test command to:
add_test(${Name} ${EXECUTABLE_OUTPUT_PATH}/${Name})

Now, when I try to build the RUN_TESTS target I get results like this:

Start processing tests
Test project /Projects/MyProject/build
  1/  1 Testing TestLibrary                    ***Failed

0% tests passed, 1 tests failed out of 1

The following tests FAILED:
      1 - TestLibrary (Failed)
Errors while running CTest
make: *** [RUN_TESTS_buildpart_0] Error 8

It is unclear why an error like this is occurring.  The test application 
runs successfully when launched manually.
How can I fix this problem so the test runs properly?
> Date: Fri, 28 Nov 2008 08:36:27 -0500
> From: Michael Jackson <mike.jackson at bluequartz.net>
> Subject: Re: [CMake] Can't run units test defined in subdirectories
> To: "Cmake cmake at cmake.org" <cmake at cmake.org>
> Message-ID: <B6CDE8B5-12B9-4FAA-AD0C-7C0557563B33 at bluequartz.net>
> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
>
> You might want to try:
>
> ADD_TEST(${Name} ${EXECUTABLE_OUTPUT_PATH}/${Name})
>
>
>
> Mike
>
> On Nov 27, 2008, at 5:42 PM, Tron Thomas wrote:
>
>   
>> I am trying to use CMake to configure a project on Mac OS X that  
>> contains different subdirectories where various libraries and such  
>> are built.  These subdirectories will also contain unit tests for  
>> the built components.  In the root CMakeLists.txt file, I have  
>> defined a macro that will help set up the unit tests when I call  
>> this macro in the sub directories.  This is the basics of how the  
>> macro works:
>>
>> macro(AddTestApplication Name)
>> 	# Generate test application information here ...
>>
>> 	add_executable(${Name} ${ARGN})
>> 	get_target_property(TestCommand ${Name} LOCATION)
>> 	add_test(${Name} ${TestCommand})
>> endmacro(AddTestApplication)
>>
>> When I include the macro in the subdirectory, the test application  
>> gets built.  When I try to run the RUN_TESTS target in the project,  
>> I get error output like:
>>
>> Start processing tests
>> Test project /Projects/MyProject/build
>>  1/  1 Testing TestLibrary                    Could not find  
>> executable /Projects/MyProject/build/$(CONFIGURATION)/TestLibrary
>> Looked in the following places:
>> /Projects/MyProject/build/$(CONFIGURATION)/TestLibrary
>> /Projects/MyProject/build/$(CONFIGURATION)/TestLibrary
>> /Projects/MyProject/build/$(CONFIGURATION)/Debug/TestLibrary
>> /Projects/MyProject/build/$(CONFIGURATION)/Debug/TestLibrary
>> Debug//Projects/MyProject/build/$(CONFIGURATION)/TestLibrary
>> Debug//Projects/MyProject/build/$(CONFIGURATION)/TestLibrary
>> Projects/MyProject/build/$(CONFIGURATION)/TestLibrary
>> Projects/MyProject/build/$(CONFIGURATION)/TestLibrary
>> Projects/MyProject/build/$(CONFIGURATION)/Debug/TestLibrary
>> Projects/MyProject/build/$(CONFIGURATION)/Debug/TestLibrary
>> Debug/Projects/MyProject/build/$(CONFIGURATION)/TestLibrary
>> Debug/Projects/MyProject/build/$(CONFIGURATION)/TestLibrary
>> Unable to find executable: /Projects/MyProject/build/$ 
>> (CONFIGURATION)/TestLibrary
>>
>> 0% tests passed, 1 tests failed out of 1
>>
>> The following tests FAILED:
>> 	  1 - TestLibrary (Not Run)
>> Errors while running CTest
>> make: *** [RUN_TESTS_buildpart_0] Error 8
>>
>> For some reason CTest is not performing any substitution for $ 
>> (CONFIGURATION).  If it were, the first location it tried would have  
>> succeeded in finding the test exectuable
>> What is needed so that the test application can run successfully?
>>     




More information about the CMake mailing list