vscode-cmake-tools
vscode-cmake-tools copied to clipboard
Enable Quick Debugging in Test Explorer like in Project Outline
This change addresses items #3345, #3280 and #3153
The following changes are proposed:
When the user debugs a test via TestExplorer/some-test/Debug-Icon now the method to create a debug configuration behind the scenes is used as when the user right-clicks an executable and used "Debug" in the PROJECT OUTLINE of cmake.
The purpose of this change
Harmonize Quick Debugging of executables and tests.
Simplify debugging of tests.
Changes in current behavior
This removes behavior introduced by PR #3064. But I think this is fine, see https://github.com/microsoft/vscode-cmake-tools/issues/3345#issuecomment-1745682834 .
This may necessary to adapt the documentation at https://github.com/microsoft/vscode-cmake-tools/blob/main/docs/debug-launch.md#debugging-tests I'd add a suggestion if you guys like.
Please have a look there as well. Thx.
Remark: I used https://github.com/basejumpa/vscode-cmake-tools-testdata as testdata while coding.
@microsoft-github-policy-service agree
@quyykk @taneadam @IlVirtuoso
As you guys are the creators of the issues addressed by this PR I'd appreciate if you could do some beta testing. You may use the vsix package from https://github.com/basejumpa/vscode-cmake-tools/actions/runs/6895050421 and install it via ˋcode --install-extension cmake-tools.vsixˋ (remove the installed one before).
I tried the original version before the force push and it didn't seem to work, saying No launch configurations found.. Did I mess something up? Thanks for working on this!
@quyykk I needed to uninstall the extension before installing the vsix package. It sounds like you didn't uninstall, either.
I did uninstall it before trying. I can try again though. However, with the latest version I get prompted to select a launch configuration instead of seeing an error, so I'm pretty sure this is caused by this PR.
@quyykk
I assume you used the "Debug C/C++m File" button in the headline of a cpp (test) file as shown in the screenshot as (1). This never was connected to vscode-cmake-tools (afaik).
You should use the "Debug Test" button in the test explorer marked by (2).
The related documentation in docs/debug-launch.md still needs to be adapted within this PR.
Here I made a video:
https://github.com/microsoft/vscode-cmake-tools/assets/85879619/ff6176be-562c-47e4-9c74-68a6dd90d80b
Doing the same thing with the latest release gives me this prompt:
@quyykk Weird! And you really installed via the command line the cmake-tools.vsix built from my feature branch at https://github.com/basejumpa/vscode-cmake-tools/actions/workflows/build-vsix.yml ?
Yeah, I used the link you posted above. I also restarted VSCode and verified that it is uninstalled before installing the file. I've also disabled Auto-Update, because it would update the extension immediately.
@quyykk
Thx for your screencast. Since I am working on Win11 and I saw you working on linux I tried it out in a github workspace (Ubuntu). Since it worked there as intended (see my screencast I assume that at your machine it didn't work to replace the extension by the vsix file.
Here are the steps I did in the screencast where I used my "try-out-zone" repository with very simple cmake projects:
- Browse to https://github.com/basejumpa/vscode-cmake-tools-testdata
- Create new codespace
- Whenever notification windows appear in the lower right then close them via the cross in their upper right corner.
- In view "TERMINAL" do ...
# Install C/C++ Extension Pack comprising debugger support for C/C++ and CMake tools
code --install-extension ms-vscode.cpptools-extension-pack
# Download and force install of the build of CMake tools of the build https://github.com/basejumpa/vscode-cmake-tools/actions/runs/6912931021
gh run download 6912931021 --repo basejumpa/vscode-cmake-tools --name=cmake-tools.vsix
code --install-extension cmake-tools.vsix --force
# Reload VScode
code --reuse-window .
- Select Kit "Clang ..."
- Build the project
- Open file
testdata-02-gtest/some_unit/some_unit_test.cpp - Set breakpoints in lines 5 and 9.
- Open view "TESTING".
- Hit "Refresh Tests" (loop icon in header)
- Debug a test.
Result:
- Breakpoint hit inside debug session. No launch config was asked for.
@basejumpa Thanks, I tried your test project on my machine and it did indeed work! So I have to assume it has something to do with the project I used. I thought it was because of presets, but I added a default preset to your project and it still worked, so I'll have to investigate some more I guess :smile:
@quyykk I now managed to use the project on branch you're currently working on (see pull-request https://github.com/endless-sky/endless-sky/pull/8095 ) with my changed extension inside a github codespace.
And you won't believe it: I have the same behavior as you had:
...
[build] Build finished with exit code 0
[main] Failed to prepare executable target with name "endless-sky-tests"
[ctest] No launch configurations found.
So now I can reproduce the behavior and work on it. I'll ping you here as soon as I have some update worth to test it. Thx in advance!
By the way: Extension C++ TestMate works like a charm with your code (since your unit tests are made with Catch2).
Steps to complete build enviornment in a GitHub codespace
code --install-extension ms-vscode.cpptools-extension-pack
# Do what the .github/workflows/ci.yml does
sudo rm /etc/apt/sources.list.d/* && sudo dpkg --clear-avail # Speed up installation and get rid of unwanted lists
sudo apt-get update
sudo apt-get install -y --no-install-recommends libxmu-dev libxi-dev libgl-dev libglu1-mesa-dev libgles2-mesa-dev libwayland-dev libxkbcommon-dev libegl1-mesa-dev libosmesa6 mesa-utils libglvnd-dev x11-utils
sudo sh -c 'echo "pcm.!default { type plug slave.pcm \"null\" }" >> /etc/asound.conf'
cmake --version
apt-get upgrade cmake
sudo apt-get upgrade cmake
cmake --version
# Get younger cmake with supports Ninja Multi-Config
# @see https://askubuntu.com/questions/355565/how-do-i-install-the-latest-version-of-cmake-from-the-command-line
# @see https://apt.kitware.com/
sudo apt remove --purge --auto-remove cmake
cmake --version
sudo apt-get upgrade
sudo apt-get update
sudo apt-get cmake
sudo apt-get install cmake
cmake --version
sudo apt update && sudo apt install -y software-properties-common lsb-release && sudo apt clean all
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
sudo apt-add-repository "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main"
sudo apt update
sudo apt install kitware-archive-keyring
sudo apt update
sudo apt install cmake
cmake --version
# Install ninja
sudo apt-get install ninja-b
# Instgall SDL2
cd ..
mkdir tmp
cd tmp
git clone https://github.com/libsdl-org/SDL.git -b SDL2
cd SDL
mkdir build
cd build
../configure
make
sudo make install
sudo apt-get install libsdl2-2.0-0
sudo apt-get install libjpeg-dev
sudo apt-get install libjpeg
sudo apt-get install libglew
sudo apt-get install libglew-dev
sudo apt-get install libopenal
sudo apt-get install libopenal-dev
sudo apt-get install libmad0-dev
# Download and force install of the build of CMake tools of the build https://github.com/basejumpa/vscode-cmake-tools/actions/runs/6912931021
gh run download 6912931021 --repo basejumpa/vscode-cmake-tools --name=cmake-tools.vsix
code --install-extension cmake-tools.vsix --force
# Reload VScode
code --reuse-window .
The "culprit" why my changes weren't effective in the endless-sky project is the renaming via
set_target_properties(EndlessSkyTests PROPERTIES OUTPUT_NAME "endless-sky-tests")
at here. When I comment out that statement it works as expected.
Steps to establish work-environment with endless-sky as testdata
Create codespace on https://github.com/microsoft/vscode-cmake-tools/pull/3451
Whenever notification dialogs appear in the lower right: Close them with the cross in their title bar.
In view "TERMINAL" do ...
# Change to home directory and get the testdata
(cd ; git clone https://github.com/quyykk/endless-sky --depth 1 --single-branch bye-codeblocks)
# Complete build environment for testdata
sudo apt-get update && sudo apt-get install libsdl2-dev libglew-dev libopenal-dev libmad0-dev
In Sidebar hit Run & Debug
Launch Extension
In the new instance of VSCode do the following:
Open folder ~/bye-codeblocks
CTRL-SHIFT-P cmake select configure preset
Select the first one on top
CTRL-SHIFT-P cmake select build preset
Select Debug
In Status Bar hit "Build"
@quyykk Now it works in your project as well. I would appreciate if you could try out the vsix from build https://github.com/basejumpa/vscode-cmake-tools/actions/runs/6991343632
@basejumpa Works on my end too, thanks!
+1
@basejumpa It seems like you've gotten some feedback that this helps out some scenarios for users, is this something you'd like to merge into the extension? If so, please convert from a draft to an official PR
@gcampbell-msft Thx for the reminder.
I'll resume working in it: Rebase my changes, double-check if things need to be adapted, add some tests, ...
As soon as it is sufficient I remove the draft flag.
@basejumpa Pinging on this.
It's been a while since there was any activity on this, is this still something you'd like to merge into the product?
My main feedback in general, is that it seems like we don't necessarily need to remove the features from #3064, but we could instead use your implementation when no launch configurations are found. This way, you can have the best of both worlds.
Please let us know if this is still something you plan to work on. Also, @basejumpa @quyykk @taneadam @IlVirtuoso Please let us know if this is something you'd like to be merged into the product, and if so, if @basejumpa doesn't plan to work on this more, we may be able to put it on our backlog to work on ourselves. Thanks!