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

Simplify debug configuration for ctest debug launch #3153

Open
PrimeMinisterOfGreed opened this issue May 1, 2023 · 10 comments
Open

Simplify debug configuration for ctest debug launch #3153

PrimeMinisterOfGreed opened this issue May 1, 2023 · 10 comments
Labels
documentation related to documentation of the extension Feature: ctest
Milestone

Comments

@PrimeMinisterOfGreed
Copy link

Brief Issue Summary

it's not clear how to write a configuration in launch.json that can debug a single test, since the default configuration launch all tests.

CMake Tools Diagnostics

No response

Debug Log

No response

Additional Information

No response

@PrimeMinisterOfGreed
Copy link
Author

i'll explain that confuse issue over there. When using TestMate c++ this extension provide a debug configuration that work by default without writing a new one in launch.json. The new cmake tools ask for a launch configuration when try to use a debugger, but after days of searching i did not encounter any tutorial that provide a way to , for example, pass the name of the selected test to the args in launch.json, this mean that also if i selected a test, all tests will be launched. If there is a way to pass such argument, this information should be provided by the extension itself or by a default launch.json configuration that indicate the presence of this argument.

@benmcmorran benmcmorran added bug a bug in the product documentation related to documentation of the extension labels May 2, 2023
@benmcmorran benmcmorran added this to the 1.15 milestone May 2, 2023
@xisui-MSFT
Copy link
Collaborator

@IlVirtuoso Can you provide the launch.json you are using?

@gcampbell-msft
Copy link
Collaborator

gcampbell-msft commented May 16, 2023

@IlVirtuoso Does the launch.json under ctest within the "debug-launch.md" file work for you?

If not, does a launch.json that looks similar to the following:

{
        "name": "CTest Launch",
        "type": "cppdbg",
        "request": "launch",
        "program": "${cmake.testProgram} ",
        "args": [ "${cmake.testArgs}" ],
    }

allow you to then debug tests from the Test Explorer?

@gcampbell-msft gcampbell-msft added the more info needed More info is needed from the community for us to properly triage and investigate. label May 16, 2023
@gcampbell-msft
Copy link
Collaborator

@IlVirtuoso Following up on this, does the above launch.json work for you? Thanks

@PrimeMinisterOfGreed
Copy link
Author

@gcampbell-msft Sorry i saw the message just now, my previous json was that

 {
            "name": "LaunchTest",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/build/DistributedCrack_test",
            "args": [
                "--gtest_filter= ${relativeFile} "
            ],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Abilita la riformattazione per gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "Imposta Versione Disassembly su Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ]
        },

i tried to catch the name of the entry and filter it in relativeFile with a custom action, but it failed. Trying to launch the .json you provide (in debug obliviously) i obtain the error launch property 'cwd' is missing.

@gcampbell-msft
Copy link
Collaborator

If you provide the same cwd from your example you sent, what happens then?

@xisui-MSFT
Copy link
Collaborator

@IlVirtuoso Are you using the test explorer? If so, my suggestion is to start debugging the test you want to debug in the test explorer. The main advantage is, using this method, ${cmake.testProgram} and ${cmake.testArgs} are expanded automatically, and you don't need to specify the details manually. Notice that, you'll have to start debugging from the test explorer, and F5 may not work.

If you are not using the test explorer, you'll need to make sure the program and args match the test item you would like to debug.

Either way, you'll need to double check that fields like fileDirname and relativeFile would be auto expanded as expected.

@gcampbell-msft gcampbell-msft added Feature: ctest and removed bug a bug in the product labels Jul 5, 2023
@gcampbell-msft gcampbell-msft removed their assignment Jul 5, 2023
@diablodale
Copy link

after following @xisui-MSFT instructions to add testProgram and testArgs, I am able to ctest debug individual tests. 👍
However, this requires me to manually select wit my mouse the launch configuration for the selected test. I see no setting in debug-launch.md or cmake-settings.md to set the default.

This is worse when I click the Debug Tests at the top of the test explorer UI. This starts ctest for each test (22 in my project).
I then have to manually wait for each test to be run by vscode and manually select the launch configuration 22 times as each test completes and the next test starts. 👎 I see no setting in debug-launch.md or cmake-settings.md to set the default.

@gcampbell-msft gcampbell-msft removed the more info needed More info is needed from the community for us to properly triage and investigate. label Jul 18, 2023
@gcampbell-msft
Copy link
Collaborator

gcampbell-msft commented Jul 18, 2023

@diablodale I'm glad you're able to ctest debug individual tests!

Thanks for your feedback regarding the usage of the Test Explorer, we will continue to use your feedback into consideration as we plan our backlog and plan for future features and work items.

@xisui-MSFT FYI

@gcampbell-msft gcampbell-msft moved this from Triage Needed to Pending Prioritization in CMake Tools Nov 29, 2023
@gcampbell-msft gcampbell-msft modified the milestones: 1.17, On Deck Nov 29, 2023
@BMBurstein
Copy link

This seems to be the same issue as #3345

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation related to documentation of the extension Feature: ctest
Projects
Status: Pending Prioritization
Development

No branches or pull requests

6 participants