execute_command(
COMMAND ${test_cmd}
COMMAND ${CMAKE_COMMAND} -E compare_files ${output_blessed} $
{output_test}
RESULT_VARIABLE test_not_successful
OUTPUT_QUIET
ERROR_QUIET
)
if( test_not_successful )
message( SEND_ERROR "${output_test} does not match $
{output_blessed}!" )
endif( test_not_successful )
and then in your CMakeLists.txt:
add_test( "someImportantTest"
${CMAKE_COMMAND}
-Dtest_cmd="${CMAKE_BINARY_DIR}/tests/someImportantTestProgram --
with arguments"
-Doutput_blessed="${CMAKE_SOURCE_DIR}/tests/output/
someImportatanTestProgram.output"
-Doutput_test="${CMAKE_BINARY_DIR}/someImportatanTestProgram.output"
-P ${CMAKE_SOURCE_DIR}/CMake/run_test.cmake
)
I have noticed that if I use
-Dtest_cmd="${CMAKE_BINARY_DIR}/tests/someImportantTestProgram --
with arguments"
it results in errors - it appears that the test_cmd variable is not
interpreted properly because the resulting process does not get
executed. For executables without arguments, removing quotes seems to
work to set test_cmd properly.
For example
# in CMakeLists.txt
add_test( dummy_1
${CMAKE_COMMAND}
-Dtest_cmd="ls -lah"
-P ${CMAKE_SOURCE_DIR}/util/try.cmake
)
# in try.cmake
if( NOT test_cmd )
message( FATAL_ERROR "Variable test_cmd not defined" )
endif( NOT test_cmd )
execute_process( COMMAND ${test_cmd} )
This does not work (e.g. the output in Testing/Temporary/LastTest.log
does not show that the command actually executed). The results in the
LastTest.log file are
Start testing: Jul 06 11:53 MDT
----------------------------------------------------------
Changing directory into: /Users/u0033394/projects/ExprLib/build/util
1/1 Testing: dummy_1
1/1 Test: dummy_1
Command: "/Applications/CMake 2.6-4.app/Contents/bin/cmake" "-
Dtest_cmd="ls -lah"" "-P" "/Users/u0033394/projects/ExprLib/util/
try.cmake"
Directory: /Users/u0033394/projects/ExprLib/build/util
"dummy_1" start time: Jul 06 11:53 MDT
Output:
----------------------------------------------------------
----------------------------------------------------------
"dummy_1" end time: Jul 06 11:53 MDT
"dummy_1" time elapsed: 00:00:00
----------------------------------------------------------
End testing: Jul 06 11:53 MDT
Any ideas?
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake