clion doesn't use WORKING_DIRECTORY property of tests

已回答

If I set a tests working_directory in the cmake file when running the test under ctest it will run the test in the correct location but clion doesn't seem to pick this up. Is there something I'm doing wrong?

For example if I have something like:

add_executable(MyTest MyTest.cpp)
add_test(NAME RunMyTest WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND MyTest)

When running the test or any test case from clion the cwd will remain the runtime directory instead of being updated to be CMAKE_CURRENT_SOURCE_DIR

 

4

Yes. Currently blocking also our testing workflow.

0

Hi Dev!

Do you use CTest and set the working directory in the CMakeLists.txt as described in the original question?

0

Breaking workflow here too. We use "add_test(… WORKING_DIRECTORY <some path> …) but CLion still runs tests in the same directory where the test binary is, not in <some path> as expected. CTest runs tests in the correct directory.

 

 

0

Hi all!

Here is the related issue in our tracker - CPP-28105. Feel free to comment or upvote the issue in order to get updates. See https://intellij-support.jetbrains.com/hc/en-us/articles/207241135-How-to-follow-YouTrack-issues-and-receive-notifications if you are not familiar with YouTrack. 

0

Anna Falevskaya I'm not sure it's exactly the same issue. CPP-28105 relates to automatically picking the working directory for individual tests (i.e. inferring the target from the test, which is not necessarily trivial).

I think that the current request is more about having the working directory automatically set to the WORKING_DIRECTORY value for a run configuration specifying that cmake target (especially when these run configurations are automatically created from the test targets when a project is initialized or a target is created).

Should a separate issue be created for that issue / feature?

0

Thomas, as far as I can see, the problem that is being discussed in this thread is that WORKING_DIRECTORY is not properly picked up from add_test(<…> WORKING_DIRECTORY <…>) by CLion. It looks to me the same as CPP-28105. But my understanding might be incorrect. If you feel that CPP-28105 does not describe the functionality you would like to observe, feel free to create another feature request/issue.

0

OK, I just added a complement of information to CPP-28105 to make the point that automatically setting the working directory when the target is automatically created is probably easier than supporting automatic detection of the actual target when right-clicking on a test (which possibly does already exist though).

0

请先登录再写评论。