Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
Qt Creator 4.8.0
-
None
Description
Some of the tests in our project use test data from files which are part of the source tree and their execution from QtCreator fails due to incorrect working directory.
Example to reproduce the issue:
- CMakeLists.txt:
cmake_minimum_required(VERSION 3.10) project(fasttest) enable_testing() find_package(GTest REQUIRED) add_executable(fasttest main.cpp) target_link_libraries(fasttest GTest::GTest GTest::Main) add_test(NAME fasttest COMMAND fasttest WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
- main.cpp:
#include <unistd.h> #include <gtest/gtest.h> TEST(WDIR, print) { char buf[40960]; getcwd(buf, 40960); buf[40959] = '\0'; std::cout << buf << '\n'; }
This test prints `/home/vestnik/Development/test/fasttest/build/host_gcc7/release` when running it from QtCreator test integration UI and `/home/vestnik/Development/test/fasttest` when running `ninja test`. As one can see the first output is incorrect.