Qt Creator 4.4.0-rc1
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:
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
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).
|For Gerrit Dashboard: QTCREATORBUG-18725|
|225254,3||AutoTest: Set gtest-result line number even if file can't be resolved||master||qt-creator/qt-creator||Status: MERGED||+2||0|