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

Autotest output: jump to location feature is unreliable when used with gtest

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Done
    • Affects Version/s: Qt Creator 4.4.0-rc1
    • Fix Version/s: None
    • Component/s: Test Integration
    • Environment:
      XUbuntu 16.04.3

      gcc 5.4.0

      clang 4.0.0

      ninja 1.5.1

      cmake 3.5.1
    • Commits:
      4e4118dd26c638ab0716bc9409c770e9e810a713 27190cd50aa2db2b4ef94c9f0fdbf77391761532

      Description

      The "jump to location" feature of the "Test Results" output pane, does not work in specific build environments when gtest is used.

      If a test fails the GTest command line output contains the path to the source file of the test.
      Autotest uses this path to enable its "jump to location" feature (double click on the entry of the failed test in the output pane).
      GTest uses the _FILE_ macro to report the test file location.
      However the concrete expansion of the _FILE_ marco is usually the path by which the C/C++ preprocessor opened the file and that
      depends on the build tools used and the location of the build directory.

      A build environment where the "jump to location" feature does not work is the following:

      Tools:

      • cmake
      • ninja
      • gcc/clang

      Project Structure:

      projectRoot/
       CMakeLists.txt
       test/
        CMakeLists.txt    # Creates the test executable
        location_test.cpp
       build/             # The build directory

      Build and run test:

      cd projectRoot/build
      cmake -G Ninja ..
      ninja
      test/location_test

      Output:

      Running main() from gtest_main.cc
      [==========] Running 1 test from 1 test case.
      [----------] Global test environment set-up.
      [----------] 1 test from LocationTest
      [ RUN ] LocationTest.fail
      ../test/location_test.cpp:4: Failure
      Value of: false
       Actual: false
      Expected: true
      [ FAILED ] LocationTest.fail (0 ms)
      ...

      The test file location is reported relative to the build/ directory,
      because ninja compiles location_test.cpp with:

      /usr/bin/c++ -o test/CMakeFiles/location_test.dir/location_test.cpp.o -c ../test/location_test.cpp

      When Autotest finds a relative path it tries to resolve it against the directory
      that contains the test executable:
      projectRoot/build/test/ + ../test/location_test.cpp = projectRoot/build/test/location_test.cpp = Not Found

      When building the same project with cmake + make + gcc/clang the absolute path to the test file is reported,
      because make compiles location_test.cpp with:

      /usr/bin/c++ -o CMakeFiles/location_test.dir/location_test.cpp.o -c /home/user/projectRoot/test/location_test.cpp

      I have appended a minimal cmake project with that layout.
      It uses the cmake external project feature to download and compile google-test, hence you can just use the commands from above
      to build it (if ninja and cmake are installed on your system).

        Attachments

        1. out
          2 kB
        2. test_jump_to_location.zip
          2 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            cstenger Christian Stenger
            Reporter:
            clst Claus Steuer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes