vscode-cmake-tools icon indicating copy to clipboard operation
vscode-cmake-tools copied to clipboard

"Go to source" in Testing activity + test panel without function

Open rsarrazin2 opened this issue 1 year ago • 2 comments

Brief Issue Summary

Description

A Google test run thanks to the CMake extension in the Testing activity doesn't lead to its source code:

  • neither by double-clicking on the Testing activity entry

image

  • nor by opening "show output" in the Testing activity then right-click on "Go to Source"

image

Minimum viable example

https://github.com/rsarrazin2/cmake_workspace_for_vscode_c_cpp_extension/tree/test-explorer-go-to-source

CMake Tools Diagnostics

{
  "os": "linux",
  "vscodeVersion": "1.82.2",
  "cmtVersion": "1.15.31",
  "configurations": [
    {
      "folder": "/home/rolands/workspace/_test/cmake_workspace_for_vscode_c_cpp_extension",
      "cmakeVersion": "3.25.1",
      "configured": true,
      "generator": "Unix Makefiles",
      "usesPresets": true,
      "compilers": {
        "C": "/usr/bin/clang",
        "CXX": "/usr/bin/clang++"
      }
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "activeBuildType": "Debug",
    "buildTypesSeen": [
      "Debug"
    ],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 6,
    "executablesCount": 2,
    "librariesCount": 4,
    "targets": [
      {
        "name": "example",
        "type": "EXECUTABLE"
      },
      {
        "name": "test_exec",
        "type": "EXECUTABLE"
      },
      {
        "name": "gmock",
        "type": "STATIC_LIBRARY"
      },
      {
        "name": "gmock_main",
        "type": "STATIC_LIBRARY"
      },
      {
        "name": "gtest",
        "type": "STATIC_LIBRARY"
      },
      {
        "name": "gtest_main",
        "type": "STATIC_LIBRARY"
      }
    ]
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    }
  ]
}

Debug Log

[main] Building folder: cmake_workspace_for_vscode_c_cpp_extension 
[main] Saving open files before configure/build
[build] Starting build
[driver] Start build test_exec
[proc] Executing command: /usr/bin/cmake --build /home/rolands/workspace/_test/cmake_workspace_for_vscode_c_cpp_extension/build/clang --target test_exec
[proc]   with environment: {"USER":"rolands","VSCODE_WSL_EXT_LOCATION":"/mnt/c/Users/rolands/.vscode/extensions/ms-vscode-remote.remote-wsl-0.81.7","SHLVL":"1","WT_PROFILE_ID":"{51855cb2-8cce-5362-8f54-464b92b32386}","HOME":"/home/rolands","WSL_DISTRO_NAME":"Ubuntu","WAYLAND_DISPLAY":"wayland-0","LOGNAME":"rolands","NAME":"Code","WSL_INTEROP":"/run/WSL/6879_interop","PULSE_SERVER":"unix:/mnt/wslg/PulseServer","_":"/mnt/c/Users/rolands/AppData/Local/Programs/Microsoft VS Code/bin/code","TERM":"xterm-256color","PATH":"/home/rolands/.vscode-server/bin/abd2f3db4bdb28f9e95536dfa84d8479f1eb312d/bin/remote-cli:/home/rolands/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/ProgramData/chocolatey/bin:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Users/rolands/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/rolands/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/rolands/AppData/Local/Programs/Git/cmd:/mnt/c/Users/rolands/AppData/Roaming/Code/User/globalStorage/ms-vscode-remote.remote-containers/cli-bin:/snap/bin","WT_SESSION":"d32313d7-f19b-4ab7-9d45-16c7b845d41b","XDG_RUNTIME_DIR":"/mnt/wslg/runtime-dir","DISPLAY":":0","LANG":"C.UTF-8","SHELL":"/bin/bash","PWD":"/mnt/c/Users/rolands/AppData/Local/Programs/Microsoft VS Code","WSL2_GUI_APPS_ENABLED":"1","HOSTTYPE":"x86_64","WSLENV":"ELECTRON_RUN_AS_NODE/w:WT_SESSION::WT_PROFILE_ID\n","VSCODE_HANDLES_SIGPIPE":"true","CPP":"/usr/bin/clang-cpp-10","CXX":"/usr/bin/clang++-10","LS_COLORS":"rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:","LD":"/usr/bin/ld.lld-10","SGX_AESM_ADDR":"1","LESSCLOSE":"/usr/bin/lesspipe %s %s","LESSOPEN":"| /usr/bin/lesspipe %s","LIBVIRT_DEFAULT_URI":"qemu:///system","XDG_DATA_DIRS":"/usr/local/share:/usr/share:/var/lib/snapd/desktop","CC":"/usr/bin/clang-10","VSCODE_AMD_ENTRYPOINT":"vs/workbench/api/node/extensionHostProcess","VSCODE_HANDLES_UNCAUGHT_ERRORS":"true","VSCODE_NLS_CONFIG":"{\"locale\":\"en\",\"osLocale\":\"en\",\"availableLanguages\":{}}","VSCODE_CWD":"/mnt/c/Users/rolands/AppData/Local/Programs/Microsoft VS Code","ELECTRON_RUN_AS_NODE":"1","VSCODE_IPC_HOOK_CLI":"/mnt/wslg/runtime-dir/vscode-ipc-21f35d8c-7ea8-427f-9d87-5785beed3a2e.sock","APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL":"1","VSCODE_L10N_BUNDLE_LOCATION":""}
[build] [ 33%] Built target gtest
[build] [ 66%] Built target gtest_main
[build] [100%] Built target test_exec
[driver] Build completed: 00:00:00.058
[cmakefileapi-parser] Read reply folder: /home/rolands/workspace/_test/cmake_workspace_for_vscode_c_cpp_extension/build/clang/.cmake/api/v1/reply
[cmakefileapi-parser] Found index files: ["cache-v2-bd072342044c900278cd.json","cmakeFiles-v1-080b1b52bf70346c9ba2.json","codemodel-v2-03cd08cdc3b76dd812c7.json","directory-.-Debug-f5ebdc15457944623624.json","directory-_deps.googletest-build-Debug-fac11ca5fe14357be6bd.json","directory-_deps.googletest-build.googlemock-Debug-e2174252b70e5588a0ca.json","directory-_deps.googletest-build.googletest-Debug-811eaff3b09bf87da5fd.json","directory-example-Debug-b6fca4a6d0a37c6ae6b9.json","directory-example.example-Debug-cc95193582d52cb8afdd.json","index-2023-10-02T10-27-24-0899.json","target-example-Debug-a2a30ee6af9180809cde.json","target-gmock-Debug-7ea1a5a9ec12221ff404.json","target-gmock_main-Debug-344e88a03911a2469042.json","target-gtest-Debug-571e2d6fe22261b6a031.json","target-gtest_main-Debug-a05e8c6f74ed5e249e80.json","target-test_exec-Debug-021be7f0c36c7d03bf90.json","toolchains-v1-77b1fedc25d3af5713c5.json"]
[build] Build finished with exit code 0
[cache] Reading CMake cache file /home/rolands/workspace/_test/cmake_workspace_for_vscode_c_cpp_extension/build/clang/CMakeCache.txt
[cache] Parsing CMake cache string
[cache] Reading CMake cache file /home/rolands/workspace/_test/cmake_workspace_for_vscode_c_cpp_extension/build/clang/CMakeCache.txt
[cache] Parsing CMake cache string
[proc] Executing command: /usr/bin/ctest -T test -R ^Foo\.Bar$
[proc]   with environment: {"USER":"rolands","VSCODE_WSL_EXT_LOCATION":"/mnt/c/Users/rolands/.vscode/extensions/ms-vscode-remote.remote-wsl-0.81.7","SHLVL":"1","WT_PROFILE_ID":"{51855cb2-8cce-5362-8f54-464b92b32386}","HOME":"/home/rolands","WSL_DISTRO_NAME":"Ubuntu","WAYLAND_DISPLAY":"wayland-0","LOGNAME":"rolands","NAME":"Code","WSL_INTEROP":"/run/WSL/6879_interop","PULSE_SERVER":"unix:/mnt/wslg/PulseServer","_":"/mnt/c/Users/rolands/AppData/Local/Programs/Microsoft VS Code/bin/code","TERM":"xterm-256color","PATH":"/home/rolands/.vscode-server/bin/abd2f3db4bdb28f9e95536dfa84d8479f1eb312d/bin/remote-cli:/home/rolands/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/ProgramData/chocolatey/bin:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Users/rolands/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/rolands/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/rolands/AppData/Local/Programs/Git/cmd:/mnt/c/Users/rolands/AppData/Roaming/Code/User/globalStorage/ms-vscode-remote.remote-containers/cli-bin:/snap/bin","WT_SESSION":"d32313d7-f19b-4ab7-9d45-16c7b845d41b","XDG_RUNTIME_DIR":"/mnt/wslg/runtime-dir","DISPLAY":":0","LANG":"C.UTF-8","SHELL":"/bin/bash","PWD":"/mnt/c/Users/rolands/AppData/Local/Programs/Microsoft VS Code","WSL2_GUI_APPS_ENABLED":"1","HOSTTYPE":"x86_64","WSLENV":"ELECTRON_RUN_AS_NODE/w:WT_SESSION::WT_PROFILE_ID\n","VSCODE_HANDLES_SIGPIPE":"true","CPP":"/usr/bin/clang-cpp-10","CXX":"/usr/bin/clang++-10","LS_COLORS":"rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:","LD":"/usr/bin/ld.lld-10","SGX_AESM_ADDR":"1","LESSCLOSE":"/usr/bin/lesspipe %s %s","LESSOPEN":"| /usr/bin/lesspipe %s","LIBVIRT_DEFAULT_URI":"qemu:///system","XDG_DATA_DIRS":"/usr/local/share:/usr/share:/var/lib/snapd/desktop","CC":"/usr/bin/clang-10","VSCODE_AMD_ENTRYPOINT":"vs/workbench/api/node/extensionHostProcess","VSCODE_HANDLES_UNCAUGHT_ERRORS":"true","VSCODE_NLS_CONFIG":"{\"locale\":\"en\",\"osLocale\":\"en\",\"availableLanguages\":{}}","VSCODE_CWD":"/mnt/c/Users/rolands/AppData/Local/Programs/Microsoft VS Code","ELECTRON_RUN_AS_NODE":"1","VSCODE_IPC_HOOK_CLI":"/mnt/wslg/runtime-dir/vscode-ipc-21f35d8c-7ea8-427f-9d87-5785beed3a2e.sock","APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL":"1","VSCODE_L10N_BUNDLE_LOCATION":""}
[ctest] Cannot find file: /home/rolands/workspace/_test/cmake_workspace_for_vscode_c_cpp_extension/build/clang/DartConfiguration.tcl
[ctest]    Site: 
[ctest]    Build name: (empty)
[ctest] Test project /home/rolands/workspace/_test/cmake_workspace_for_vscode_c_cpp_extension/build/clang
[ctest]     Start 1: Foo.Bar
[ctest] Cannot find file: /home/rolands/workspace/_test/cmake_workspace_for_vscode_c_cpp_extension/build/clang/DartConfiguration.tcl
[ctest] 1/1 Test #1: Foo.Bar ..........................   Passed    0.00 sec
[ctest] 
[ctest] 100% tests passed, 0 tests failed out of 1
[ctest] 
[ctest] Total Test time (real) =   0.00 sec
[ctest] CTest finished with return code 0

Additional Information

No response

rsarrazin2 avatar Oct 02 '23 10:10 rsarrazin2

Thanks for the report! We'll attempt to reproduce this issue using the repo you provided at let you know if we need any additional information.

benmcmorran avatar Oct 03 '23 19:10 benmcmorran

I am having the same issue. I don't think the "Go to code" feature ever worked when using gtest_discover_tests() but it's the recommended way to find tests created using gtest. I have been trying this on and off for quite some time, even before cmake was using the native test explorer. It's quite an inconvenience as I then need to start searching for the test via its name.

bertbuchholz avatar Dec 20 '23 11:12 bertbuchholz

UPDATE:

  • Pull request made to fix this issue, and #3631
  • CMake pull request under review. Expecting to be merged for CMake 3.30

OLD: ~~I'm leaving this here in case it could help anyone.~~

~~I made a minor change to allow "Go to test" to work. https://github.com/microsoft/vscode-cmake-tools/compare/main...danniesim:vscode-cmake-tools:dev/danniesim/GTestGoToTest~~

~~The solution requires a small change to the Google Test CMake module: https://gitlab.kitware.com/danniesim/cmake/-/compare/master...gtest-json-test-def-source?from_project_id=541~~

~~I am not expecting it to be merged in both repositories, but I am pretty pleased that my code->test_>repeat workflow is what I like it to be now.~~

danniesim avatar Mar 01 '24 20:03 danniesim