Open PrimeMinisterOfGreed opened 1 year ago
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.
@IlVirtuoso Can you provide the launch.json you are using?
@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?
@IlVirtuoso Following up on this, does the above launch.json work for you? Thanks
@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.
If you provide the same cwd
from your example you sent, what happens then?
@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.
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.
@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
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