Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Quick Debugging in Test Explorer like in Project Outline #3451

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

basejumpa
Copy link

@basejumpa basejumpa commented Nov 16, 2023

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 #3345 (comment) .

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.

@basejumpa
Copy link
Author

@microsoft-github-policy-service agree

@basejumpa
Copy link
Author

basejumpa commented Nov 17, 2023

@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).

@basejumpa basejumpa changed the title Same Quick Debugging in Test Explorer as in Project Outline Enable Quick Debugging in Test Explorer like in Project Outline Nov 17, 2023
@quyykk
Copy link

quyykk commented Nov 18, 2023

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!

@basejumpa
Copy link
Author

@quyykk I needed to uninstall the extension before installing the vsix package. It sounds like you didn't uninstall, either.

@quyykk
Copy link

quyykk commented Nov 19, 2023

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.

@basejumpa
Copy link
Author

@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).

image

The related documentation in docs/debug-launch.md still needs to be adapted within this PR.

@quyykk
Copy link

quyykk commented Nov 20, 2023

Here I made a video:

cmake-test1.mp4

Doing the same thing with the latest release gives me this prompt:

image

@basejumpa
Copy link
Author

@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 ?

@quyykk
Copy link

quyykk commented Nov 20, 2023

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.

@basejumpa
Copy link
Author

basejumpa commented Nov 22, 2023

@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:

# 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.

@quyykk
Copy link

quyykk commented Nov 22, 2023

@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 😄

@basejumpa
Copy link
Author

basejumpa commented Nov 22, 2023

@quyykk I now managed to use the project on branch you're currently working on (see pull-request endless-sky/endless-sky#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 .

@basejumpa basejumpa marked this pull request as draft November 22, 2023 17:45
@basejumpa
Copy link
Author

basejumpa commented Nov 25, 2023

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 #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"

@basejumpa
Copy link
Author

basejumpa commented Nov 25, 2023

@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

@quyykk
Copy link

quyykk commented Nov 28, 2023

@basejumpa Works on my end too, thanks!

@weyllor
Copy link

weyllor commented Apr 20, 2024

+1

@gcampbell-msft
Copy link
Collaborator

@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

@basejumpa
Copy link
Author

@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.

@gcampbell-msft
Copy link
Collaborator

@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!

@basejumpa
Copy link
Author

basejumpa commented Oct 26, 2024

@gcampbell-msft

This topic hasn't bothered me the recent months only because currently I am busy with other topics.

Shall mean please feel free to tackle this topic, maybe my old work towards some solution may help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants