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

running ctest using test explore with env vars from test presets #4313

Open
mikirothman opened this issue Feb 27, 2025 · 3 comments
Open

running ctest using test explore with env vars from test presets #4313

mikirothman opened this issue Feb 27, 2025 · 3 comments

Comments

@mikirothman
Copy link

Brief Issue Summary

hello
our test presets have bunch of environment variables (composed by conan due to our dependency graph) which we need in order to launch the tests,
we were expecting to see those vars along the ctest command.
but the command ctest invokes is:

ctest.exe -T test --output-on-failure --build-config Debug -R ^MyProj\.MyTest$

Due to the missing env vars the tests fail when running from the test explorer.
Running ctest —preset ${my-preset} from the terminal pass the env vars to my test executables

CMake Tools Diagnostics

Debug Log

Additional Information

No response

@Yingzi1234
Copy link
Collaborator

@mikirothman Thank you for your github issue! To be able to reproduce your question better, can you help us answer the following question?

  1. How do you run CTest?
    Did you run the test through VSCode's CTest Explorer or did you run the CTest command manually?
    If VSCode, please confirm how VSCode invokes ctest? (e.g., did it use the CTest: Run Tests button?)
    If running manually, please provide the full command and terminal output. 2.
  2. how are your CMake presets (CMakePresets.json) defined?
    Could you share CMakePresets.json or the relevant CTest preset section?
    (especially the environment field to see if the environment variables are actually defined in the preset)

@Yingzi1234 Yingzi1234 added more info needed More info is needed from the community for us to properly triage and investigate. and removed triage labels Feb 28, 2025
@mikirothman
Copy link
Author

  1. How do you run CTest?
    We tried with vscode, both with Run CTest button from the Status bar and from the test explorer.
    we doubled checked that the active preset is configured properly with the desired preset.
    when running manually, everything works as expected.

  2. how are your CMake presets (CMakePresets.json) defined?
    Not sure I understand the question; they are defined according to docs.
    we have several environment variables defined in the preset, which are missing from the test executables when running from vscode.
    the fact that running from command line with the desired preset is kinda of a proof that the issue is not at the preset side.

@Yingzi1234
Copy link
Collaborator

@mikirothman @gcampbell-msft We can reproduce this issue on latest version CMake Tools1.21.2(pre-release), you can get the details below. Thank you!

Environment:
Linux: Ubuntu 22.04.4LTS

Repro steps:

  1. Download this folder ctest_env_test.tar.gz and open it with VSCode
  2. Click F1 to run command CMake: configure
  3. Open terminal window and run below code
cmake --preset default
ctest --preset default
  1. Check if can be run successfully
  2. Open the Testing page and click on the Run Test button of Myproj.MyTest line
  3. Check if can be run successfully

Actual result:
Running CTest manually works, but running it inside VSCode fails
Image

@Yingzi1234 Yingzi1234 added bug a bug in the product and removed more info needed More info is needed from the community for us to properly triage and investigate. labels Mar 5, 2025
@gcampbell-msft gcampbell-msft added this to the 1.21 milestone Mar 5, 2025
@gcampbell-msft gcampbell-msft moved this from Blocked to Pending Prioritization in CMake Tools Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Pending Prioritization
Development

No branches or pull requests

3 participants