Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-21774

Cmake add_test WORKING_DIRECTORY parameter is ignored by QtCreator test integration

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • Qt Creator 4.8.0
    • Test Integration
    • 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.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            cstenger Christian Stenger
            s.vidyuk Sergey Vidyuk
            Votes:
            4 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes