I would like to run a command for my C++ project such as ./unittests_feature1 --gtest_filter=Feature1.test_int
using Visual Studio Code Debugger.
When setting up a debugger session in Visual Studio, my configuration looks like this:
{
"name": "Test_int",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/unittests_feature1",
"args": ["--gtest_filter=Feature1.test_int"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
But when I start the Debugger, it runs everything for unittests_feature1, and not only Feature1.test_int.
If I run manually in command line:
gdb --args ./unittests_feature1 --gtest_filter=Feature1.test_int
It works, so some Visual Studio Code configurations might be the problem.
I got a similar problem today and I'de like to post some experience here to help.
I am using WSL2/Ubuntu & VSCode Remote-WSL to debug a C++ program with GTest code. The default terminal in WSL2/Ubuntu is zsh. I want to pass the argument "--gtest_filter=OneD* to the test executable.
For me, the successful config for the args field of the launch.json is:
"args": [
"--gtest_filter=OneD\\*"
],
Examples of problematic configs include:
[--gtest_filter=\"OneD\\*\"][--gtest_filter=\"OneD*\"][--gtest_filter=OneD*]It seems zsh contributed a little to the problem since * is parsed by zsh firstly before gdb & my executable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With