Register cmake.testProgram, cmake.testWorkingDirectory, cmake.testArgs as VS Code commands#4701
Open
Register cmake.testProgram, cmake.testWorkingDirectory, cmake.testArgs as VS Code commands#4701
Conversation
Copilot
AI
changed the title
[WIP] Fix ctest debug launch program error
Register cmake.testProgram, cmake.testWorkingDirectory, cmake.testArgs as VS Code commands
Feb 9, 2026
…s as VS Code commands Fixes #4574 - The ${cmake.testProgram}, ${cmake.testWorkingDirectory}, and ${cmake.testArgs} variables were only resolved internally by CMake Tools when debugging from the Test Explorer. They were not registered as VS Code commands, so using ${command:cmake.testProgram} in launch.json from the Run and Debug panel would fail with "program does not exist". Changes: - Make testProgram, testWorkingDirectory, testArgs public on CTestDriver - Add corresponding methods to ExtensionManager with test name quick pick - Register them in the funs array and package.json activation events - Handle ${command:cmake.testProgram} form in debugCTestImpl for Test Explorer - Update docs to recommend ${command:cmake.testProgram} format - Add CHANGELOG entry Co-authored-by: hanniavalera <90047725+hanniavalera@users.noreply.github.com>
Co-authored-by: hanniavalera <90047725+hanniavalera@users.noreply.github.com>
0185023 to
f2167f9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change addresses item #4574
This changes visible behavior
The following changes are proposed:
cmake.testProgram,cmake.testWorkingDirectory, andcmake.testArgsas VS Code commands so they work as${command:cmake.testProgram}in launch.json from the Run and Debug panel${cmake.testProgram}and${command:cmake.testProgram}forms in the Test Explorer debug flow${command:...}formThe purpose of this change
${cmake.testProgram}and related variables were only resolved internally during Test Explorer debugging (debugCTestImpl). They were never registered as VS Code commands, so launching a debug config containing these variables from the Run and Debug panel failed with:Users can now use
${command:cmake.testProgram}in launch.json, which VS Code resolves as a command substitution. When invoked from Run and Debug (no test context), the user is prompted to select a test via quick pick.{ "name": "(ctest) Launch", "type": "cppdbg", "request": "launch", "program": "${command:cmake.testProgram}", "args": ["${command:cmake.testArgs}"], "cwd": "${command:cmake.testWorkingDirectory}" }Other Notes/Information
Changes by file:
src/ctest.ts— MaketestProgram(),testWorkingDirectory(),testArgs()public; add${command:...}form replacement indebugCTestImplsrc/extension.ts— AddpickTestName()helper + three new command methods onExtensionManager; register infunsarraypackage.json— Add activation events for the three commandsdocs/debug-launch.md— Document both variable forms; update examples to use${command:...}CHANGELOG.md— Add bug fix entryBackward compatible: existing
${cmake.testProgram}(withoutcommand:) continues to work from the Test Explorer.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
0psvsblobprodwus2145.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install conntrack --ctstate INVALID,NEW -j DROP(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install --registry REDACTED --ignore-scripts -j ACCEPT(dns block)2wrvsblobprodwus2180.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install --registry REDACTED(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install ep/bin/linux-x64/rg(dns block)40vvsblobprodwus2135.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install conntrack --ctstate INVALID,NEW -j DROP(dns block)5bdvsblobprodwus2128.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install conntrack --ctstate INVALID,NEW -j DROP(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install --registry REDACTED --ignore-scripts -j ACCEPT(dns block)7t8vsblobprodwus2168.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install conntrack --ctstate INVALID,NEW -j DROP(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install --registry REDACTED --ignore-scripts -j ACCEPT(dns block)b15vsblobprodwus2164.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install --registry REDACTED(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install ep/bin/linux-x64/rg(dns block)b53vsblobprodwus2154.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install --registry REDACTED(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install ep/bin/linux-x64/rg(dns block)d94vsblobprodwus2119.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install --registry REDACTED(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install ep/bin/linux-x64/rg(dns block)ezcvsblobprodwus2170.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install conntrack --ctstate INVALID,NEW -j DROP(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install --registry REDACTED --ignore-scripts -j ACCEPT(dns block)k4pvsblobprodwus2140.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install conntrack --ctstate INVALID,NEW -j DROP(dns block)n6wvsblobprodwus2123.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install --registry REDACTED(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install ep/bin/linux-x64/rg(dns block)p2tvsblobprodwus2189.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install --registry REDACTED(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install ep/bin/linux-x64/rg(dns block)v41vsblobprodwus2175.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install --registry REDACTED(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install ep/bin/linux-x64/rg(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
This section details on the original issue you should resolve
<issue_title>[Bug] launch:program '${cmake.testProgram}' does not exist</issue_title>
<issue_description>### Brief Issue Summary
ctest debug no longer works when I click from Debug > Run and Debug, just states "launch:program '${cmake.testProgram}' does not exist"
launch.json
settings.json
CMake Tools Diagnostics
{ "os": "linux", "vscodeVersion": "1.104.1", "cmtVersion": "1.21.36", "configurations": [ { "folder": "/workspaces/iot-hub-device-update", "cmakeVersion": "3.23.2", "configured": true, "generator": "Ninja", "usesPresets": false, "compilers": { "C": "/usr/bin/gcc", "CXX": "/usr/bin/g++" } } ], "cpptoolsIntegration": { "isReady": true, "hasCodeModel": true, "activeBuildType": "Debug", "buildTypesSeen": [ "Debug" ], "requests": [ "file:///workspaces/iot-hub-device-update/src/utils/workflow_utils/tests/workflow_utils_ut.cpp" ], "responses": [], "partialMatches": [], "targetCount": 93, "executablesCount": 2, "librariesCount": 63, "targets": [] }, "settings": [ { "communicationMode": "automatic", "useCMakePresets": "auto", "configureOnOpen": true } ] }Debug Log
[main] Building folder: /workspaces/iot-hub-device-update/out [main] Saving open files before configure/build [build] Starting build [driver] Start build all [proc] Executing command: /tmp/deviceupdate-cmake/bin/cmake --build /workspaces/iot-hub-device-update/out --config Debug --target all -- [proc] with environment: {"HOSTNAME":"3cc60b8b140d","HOME":"/home/vscode","PATH":"/vscode/vscode-server/bin/linux-x64/0f0d87fa9e96c856c5212fc86db137ac0d783365/bin/remote-cli:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/vscode/.local/bin","SHELL":"/bin/bash","PWD":"/vscode/vscode-server/bin/linux-x64/0f0d87fa9e96c856c5212fc86db137ac0d783365","VSCODE_CWD":"/vscode/vscode-server/bin/linux-x64/0f0d87fa9e96c856c5212fc86db137ac0d783365","VSCODE_NLS_CONFIG":"{\"userLocale\":\"en\",\"osLocale\":\"en\",\"resolvedLanguage\":\"en\",\"defaultMessagesFile\":\"/vscode/vscode-server/bin/linux-x64/0f0d87fa9e96c856c5212fc86db137ac0d783365/out/nls.messages.json\",\"locale\":\"en\",\"availableLanguages\":{}}","VSCODE_HANDLES_SIGPIPE":"true","VSCODE_ESM_ENTRYPOINT":"vs/workbench/api/node/extensionHostProcess","VSCODE_HANDLES_UNCAUGHT_ERRORS":"true","REMOTE_CONTAINERS_IPC":"/tmp/vscode-remote-containers-ipc-f5edd349-ab49-44d0-81cc-403b4037dc99.sock","LS_COLORS":"","REMOTE_CONTAINERS_SOCKETS":"[\"/tmp/vscode-ssh-auth-f5edd349-ab49-44d0-81cc-403b4037dc99.sock\",\"/tmp/.X11-unix/X5\",\"/home/vscode/.gnupg/S.gpg-agent\"]","USER":"vscode","SHLVL":"1","PROMPT_DIRTRIM":"4","_":"/bin/cat","SSH_AUTH_SOCK":"/tmp/vscode-ssh-auth-f5edd349-ab49-44d0-81cc-403b4037dc99.sock","DISPLAY":":5","REMOTE_CONTAINERS_DISPLAY_SOCK":"/tmp/.X11-unix/X5","REMOTE_CONTAINERS":"true","BROWSER":"/vscode/vscode-server/bin/linux-x64/0f0d87fa9e96c856c5212fc86db137ac0d783365/bin/helpers/browser.sh","ELECTRON_RUN_AS_NODE":"1","VSCODE_IPC_HOOK_CLI":"/tmp/vscode-ipc-b626f353-4bbf-4342-8f78-7aa45763d6e2.sock","VSCODE_L10N_BUNDLE_LOCATION":"","APPLICATION_INSIGHTS_NO_STATSBEAT":"true","NINJA_STATUS":"[%s/%t %p :: %e] "} [build] ninja: no work to do. [driver] Build completed: 00:00:00.029 [cmakefileapi-parser] Read reply folder: /workspaces/iot-hub-device-update/out/.cmake/api/v1/reply [cmakefileapi-parser] Found index files: ["cache-v2-03971b698f03b73c2820.json","cmakeFiles-v1-3cc9b643bd55ab018470.json","codemodel-v2-7d4a7027335ae99a1ac2.json","directory-.-Debug-f5ebdc15457944623624.json","directory-daemon-Debug-a8788f423dcbf5060187.json","directory-src-Debug-b6cf2213fc5053b67c22.json... </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes microsoft/vscode-cmake-tools#4574 <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).