Bug 349378

Summary: ctest unit tests run in the wrong working directory
Product: [Applications] kdevelop Reporter: Barade <barade.barade>
Component: Build tools: CMakeAssignee: kdevelop-bugs-null
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 4.7.1   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 5.2.0

Description Barade 2015-06-19 10:16:54 UTC
Using the following code to create a test with CTest:

find_program(VALGRIND_EXECUTABLE valgrind)
    message(STATUS "Valgrind in ${VALGRIND_EXECUTABLE}")
    configure_file(project.supp project.supp)
    set(BOOST_TEST_ARGS --catch_system_errors=no)
    
    set(VALGRIND_HELGRIND_OPTIONS --tool=helgrind --suppressions=${CMAKE_CURRENT_BINARY_DIR}/project.supp --xml=yes --read-var-info=yes)
    add_test(NAME TestHelgrind COMMAND ${VALGRIND_EXECUTABLE} ${VALGRIND_HELGRIND_OPTIONS} --xml-file=${CMAKE_CURRENT_BINARY_DIR}/test.xml ${CMAKE_CURRENT_BINARY_DIR}/test ${BOOST_TEST_ARGS})

It always tries to run in /usr/bin where valgrind is found and not in the current binary directory as the documentation of add_test() states. Even if I set WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" which should be the default.

Reproducible: Always
Comment 1 Rolf Eike Beer 2017-07-13 05:02:30 UTC
Git commit 5c65da19fc4451eb02f3e2354764fd272ce33949 by Rolf Eike Beer.
Committed on 13/07/2017 at 04:58.
Pushed by dakon into branch 'master'.

pass all test properties to CTestSuite

Summary:
This way this and CTestRunJob can do any adaptions to the properties without
needing more and more members.

CTest: parse the test properties from CTestTestfile.cmake

Otherwise e.g. the WILL_FAIL check in ctestutils.cpp will never match as the
property hash is always empty.

CTest: honor the WORKING_DIRECTORY property of tests
FIXED-IN:5.2.0

CTest: use the test name as name instead of the executable name

Now one only needs to get rid of the first argument that is sometimes appended.

Subscribers: kdevelop-devel

Differential Revision: https://phabricator.kde.org/D6668

M  +1    -1    projectmanagers/cmake/testing/ctestrunjob.cpp

https://commits.kde.org/kdevelop/5c65da19fc4451eb02f3e2354764fd272ce33949
Comment 2 Rolf Eike Beer 2017-07-13 05:02:55 UTC
Git commit 569a9e03eca189d68db3f9ef9b854d446c473afd by Rolf Eike Beer.
Committed on 13/07/2017 at 04:54.
Pushed by dakon into branch 'master'.

CTest: honor the WORKING_DIRECTORY property of tests
FIXED-IN:5.2.0

M  +6    -2    projectmanagers/cmake/testing/ctestrunjob.cpp

https://commits.kde.org/kdevelop/569a9e03eca189d68db3f9ef9b854d446c473afd