Do not use environment variables when empty#48
Conversation
|
@corrodedHash Hi, thanks for contributing! I am a bit surprised by this issue, as neither cmake_path nor the environment getter syntax ( I couldn't reproduce this issue with the following example: cmake_path(CONVERT "UNINITIALIZED_VAR" TO_CMAKE_PATH_LIST RESULT)
cmake_path(CONVERT "$ENV{UNINITIALIZED_VAR}" TO_CMAKE_PATH_LIST RESULT)Could you give me more details about your use case? (Cmake version, platform, etc) |
|
I now know this error came from my "warnings": {
"uninitialized": true,
},
"errors": {
"dev": true,
}Or the CMake flags I copied the two Pytest CMake files into my tree, which is probably why the linting is also triggering there. As such, this is not a defect of this project. |
|
I'm still struggling to reproduce this error with your presets, or their corresponding command line options: Is there anything I'm missing? Safeguarding against uninitialized variables can be indeed important in the context of restricted settings, but I just want to ensure I can reliably reproduce this issue for confirmation. |
|
The godbolt explorer was a great idea, thank you! It seems to be doing some work in the background, if I execute the two lines on my system, I get warnings that I should use With |
|
Ah, I see! CMake behaves differently when used as a script vs. as a project builder, that's a strange one. Good catch! |
CMake reported uninitialized variable errors for `LD_LIBRARY_PATH` and `PYTHONPATH` when using `-Werror=dev --warn-uninitialized`, causing `pytest_discover_tests` to fail.
Hello,
thank you for making this!
Worked almost flawlessly, but CMake had one error:
It seemed unhappy when the environment variables were not defined.
I am uncertain if I am using it wrong, or maybe this check is only done in newer versions of CMake, I made a little change to only convert the paths if the environment variables are not empty.