Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra Ctest Env vars: Also support dotenv file #44

Open
SpaceIm opened this issue Dec 1, 2021 · 3 comments
Open

Extra Ctest Env vars: Also support dotenv file #44

SpaceIm opened this issue Dec 1, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@SpaceIm
Copy link

SpaceIm commented Dec 1, 2021

Currently, CMake test explorer allows to hardcode env vars in cmakeExplorer.extraCtestEnvVars.
But there is no way to load env vars from a dotenv file like in C/C++ extension debugging configuration (https://code.visualstudio.com/docs/cpp/launch-json-reference#_environment-variable-definitions-file).

It would be convenient to add this feature.
I'm using conan (C/C++ package manager), and I need to initialize several environment variables (PATH, LD_LIBRARY_PATH or DYLD_LIBRARY_PATH basically), before running executables having runtime dependencies. conan can generate a shell to source, a .bat for windows, and a dotenv file.
The content of those environment variables can be very complex, it can change after an update of the dependency graph, or a switch between CMake build types, so hardcoding env vars in cmakeExplorer.extraCtestEnvVars is not an option here.

@fredericbonnet fredericbonnet added the enhancement New feature or request label Dec 1, 2021
@fredericbonnet
Copy link
Owner

That's a good idea, I'll add dotenv support in the next version. BTW do you know the order of precedence between environment and envFile? envFile is supported by VS Code directly in debug mode, however it needs special support for run mode 1 and I want to keep the same semantics for both.

Footnotes

  1. reading the dotenv file and passing its content to Node child_process.spawn

@SpaceIm
Copy link
Author

SpaceIm commented Dec 1, 2021

@fredericbonnet thanks for considering this feature.

BTW do you know the order of precedence between environment and envFile? envFile is supported by VS Code directly in debug mode

AFAIK it's not supported directly by VSCode, I mean it's specific to each VSCode debugging configuration. For example C/C++ extension supports envFile, node debugging type also, or python extension, but not (yet) CodeLLDB extension. So I guess that order of precedence is implementation specific.
I guess envFile could be injected first, then environment since the later is more specific.
Anyway both should be injected. If you do something like this: PATH="<somepath>:$PATH" (Unix) or PATH=<somepath>;%PATH% (Windows) in each one, it's additive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants