DavidSchuldenfrei/gtest-adapter

Goto Test does not work with gtest 1.8.1

Closed this issue · 8 comments

svak commented

Windows 10 + VSCode 1.27.2

Test list and launch/debug works fine.
But "Go to Code" item does not work neither with googletest release-1.8.1 or master.

Is there any solutions available for that issue?

(Already read google/googletest#1658)

svak commented
  1. install vscode
  2. install "C/C++ 0.18.1" (ms) extension
  3. install "CMake" (twxs) and "CMake Tools" (vector-of-bool) extension
  4. build googletest
    $ git clone https://github.com/google/googletest.git && cd googletest
    $ git checkout release-1.8.1
    $ mkdir build && cd build && cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=Work/gtest ..

$ ninja -j6 install
5. Create simple project within vscode:

CMakeLists.txt

cmake_minimum_required(VERSION 3.10)
project(testadapter)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
enable_testing()
set(GTEST_ROOT "Work/gtest")
set(GTEST_INCLUDE_DIRS "${GTEST_ROOT}/include")
set(GTEST_LIBRARY "${GTEST_ROOT}/lib/gtestd.lib")
set(GMOCK_LIBRARY "${GTEST_ROOT}/lib/gmockd.lib")
set(GTEST_MAIN_LIBRARY "${GTEST_ROOT}/lib/gtest_maind.lib")
set(GTEST_LIBS ${GTEST_LIBRARY} ${GMOCK_LIBRARY} ${GTEST_MAIN_LIBRARY})
include_directories(${GTEST_INCLUDE_DIRS})
add_executable(testadapter main.cpp)
target_link_libraries(testadapter ${GTEST_LIBS})

main.cpp

#include <gtest/gtest.h>
#include <gmock/gmock.h>

TEST(TestAdapter, CheckOne)
{
    EXPECT_TRUE(false);
}

  1. install gtest-adapter extension, settings.json:
{
    "gtest-adapter.debugConfig": "(Windows) Launch",
    "gtest-adapter.supportLocation": true
}
  1. build project
  2. testadapter run successfully with some expected output:
[----------] 1 test from TestAdapter
[ RUN      ] TestAdapter.CheckOne
..\main.cpp(28): error: Value of: false
  Actual: false
Expected: true
[  FAILED  ] TestAdapter.CheckOne (9 ms)
  1. Now. Within "Test" view press "Refresh". Everything (but "Go to Code") is fine. Test "TestAdapter/CheckOne" appear in the tree, it can be run and debug.

  2. Press "Go to Code" and nothing will be happend.

@svak Thanks for reporting this issue.
I believe that version 1.2.2 fixes this issue. Could you confirm that with this new version Go to Test does indeed work as expected, and I will then close this.
Thank you,

David

svak commented

Unfortunately, after upgrading to version 1.2, the issue is not fixed.

Within Developers Tools/Console i can see that message:

"cannot open file:///../main.cpp. Detail: File not found (file:///../main.cpp)

@svak Would you mind sending me the unit test app, by mail. Also send me where Main.cpp is located relative to the workspace folder.

svak commented

@DavidSchuldenfrei

  1. google test installed to C:\Users\svak\SDK\gtest
  2. environment variable SDK_ROOT set to C:\Users\svak\SDK
  3. sample project located: C:\Users\svak\Temp\checkone
  4. main.cpp path: C:\Users\svak\Temp\checkone\main.cpp

Unpack to %USERPROFILE%
checkone.zip

Thank you!

@svak Could you send just the compiled executable (and the content of the build/compile_commands.json file)?
Thanks,

David

@svak Thanks for your help in finding this issue. I hadn't accounted for the fact that sometimes, a file location might start with ../ (or ..\ in Windows).
This is fixed by PR #13 and in version 1.2.3
If you still encounter problems, please reopen this issue.