Bug 349378 - ctest unit tests run in the wrong working directory
Summary: ctest unit tests run in the wrong working directory
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Build tools: CMake (show other bugs)
Version: 4.7.1
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-19 10:16 UTC by Barade
Modified: 2017-07-13 05:02 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 5.2.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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