我有两个cmake unit-test来检查url和json助手类,在我的项目的CMakeLists.txt中声明如下:
########################################
# CMakeLists.txt - Tests #
########################################
add_executable(urltest test/url.cpp)
add_test(NAME URLTest COMMAND urltest)
add_executable(jsontest test/json.cpp)
add_test(NAME JSONTest COMMAND jsontest )
我在VSCode的testing视图中直观地得到了测试单元,并且我可以在发布模式下完美地运行这两个单元:Execute the unit tests in release mode
现在,如果我想用另一个按钮调试它,我必须选择一个启动配置,为每个单元测试手动创建一个启动配置需要什么:Execute the unit tests in debug mode
我目前的launch.json文件要求每个单元测试都有一个配置,这是不可能维护的:
{ // launch.json
"version": "0.2.0",
"configurations": [
{
"name": "CTest-urltest",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/build/urltest",
"args": [],
"initCommands": ["breakpoint set -n main -N entry"],
"exitCommands": ["breakpoint delete entry"],
"cwd": "${workspaceFolder}"
},
{
"name": "CTest-jsontest",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/build/jsontest",
"args": [],
"initCommands": ["breakpoint set -n main -N entry"],
"exitCommands": ["breakpoint delete entry"],
"cwd": "${workspaceFolder}"
}
]
}
我猜问题只出在program
属性上,如何将VSCode的testing视图上点击的程序Map到唯一的启动配置?例如:
{ // launch.json
"version": "0.2.0",
"configurations": [
{
"name": "CTest",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/build/${command: testing.currentPath}",
"args": [],
"initCommands": ["breakpoint set -n main -N entry"],
"exitCommands": ["breakpoint delete entry"],
"cwd": "${workspaceFolder}"
}
]
}
1条答案
按热度按时间snz8szmq1#
我们如何将VSCode测试视图中单击的程序Map到唯一的启动配置?
这似乎在https://github.com/microsoft/vscode-cmake-tools/blob/main/docs/debug-launch.md中有记录。
在launch.json中,您可以在
program
中使用此值进行调试配置