microsoft / microsoft/vscode-cmake-tools
Missing preset environment when debugging unit tests with ctest ?
- Dominant language
- TypeScript
- Stars
- 1.7k
- Forks
- 546
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 32
Description
### Brief Issue Summary
I'm using CMake presets (configure, build and test presets) with some environment variables pointing to various DLLs required at runtime (Windows).
When running or debugging a target executable, the environement is picked up and it works fine.
When running (not debugging) unit-tests, either from the "CMake: Run tests" task or from the testing window (running individual test cases), it works fine.
However when **debugging individual unit-tests from the Testing window** the DLLs fail to load and nothing can be run. The preset environment variables seem therefore not used in the latter case.
I wonder if it comes from the extension or the way I'm trying to debug unit tests. Again, if running or debugging the test executable there is no problem, the issue arises when debugging the test cases individually from the "Testing" window:

I'm using a launch.json config of the form:
``` json
{
"name": "CTest Launch",
"type": "cppdbg",
"request": "launch",
"program": "${cmake.testProgram} ",
"args": [ "${cmake.testArgs}" ]
}
```
NB: If the environement is not required, debugging individual unit test cases works perfectly fine with my setup.
Contributor guide
Research direction
Start by reproducing the issue from the CMake presets and the launch.json configuration, using the Testing window to debug an individual CTest case. Compare that path with the working CMake: Run tests task and executable debugging, and verify that the preset environment variables are available when the individual test is debugged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp, typescript
- Domain
- build-system, devtools, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100