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

Environment variables are accessible in UWP/WinRT apps #4180

Merged
merged 1 commit into from
Mar 16, 2023

Conversation

sergio-nsk
Copy link
Contributor

Environment variables, for example GTEST_FILTER, GTEST_OUTPUT can be set before getting WinRT app run. GoogleTest can read environment variables and use them. It's easier than setting and passing command line parameters to WinRT app.

Environment variables, for example `GTEST_FILTER`, `GTEST_OUTPUT` can be set
before getting WinRT app run. GoogleTest can read environment variables and use
them. It's easier than setting and passing command line parameters to WinRT app.
@higher-performance
Copy link
Collaborator

Hi, thanks for the contribution. To clarify, have you tested that this change does what you intend?
I'm a bit confused because I see here that

This API cannot be used in applications that execute in the Windows Runtime.

which suggests to me this change shouldn't work.

@sergio-nsk
Copy link
Contributor Author

sergio-nsk commented Mar 10, 2023

@higher-performance Yes, of course I tested it. My first approach was using command line parameters, but this is so an extra hard task for UWP/WinRT applications, then I tried using environment variables and discovered that disabled code block, enabled it, and it worked perfectly. Honestly, I took a look at GetEnvironmentVariable() and I didn't see what could prevent getenv() from working:

Minimum supported client Windows XP [desktop apps | UWP apps]
Minimum supported server Windows Server 2003 [desktop apps | UWP apps]

image

image

@higher-performance
Copy link
Collaborator

Thanks. Yeah, I assumed it's not that getenv wouldn't work, but that getenv (unlike GetEnvironmentVariableA) wasn't declared for WinRT. But looking at the headers, I don't see that right now. I'm not familiar with UWP or WinRT personally, so I'm not sure why this macro was there in the first place, and I'd need to figure that out before I can feel comfortable approving this. Let me see if I can figure that out. Thanks for the contribution!

@copybara-service copybara-service bot merged commit e49c6b9 into google:main Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants