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 for setup and test tasks #215

Merged
merged 4 commits into from
Mar 9, 2024

Conversation

ptomato
Copy link
Contributor

@ptomato ptomato commented Jan 4, 2024

This adds two options, configureEnvironment and testEnvironment, allowing users to set particular environment variables during meson setup and meson test.

Closes: #9

@ptomato
Copy link
Contributor Author

ptomato commented Jan 4, 2024

I'm not really sure if this is the right way to do it, so please be zealous in reviewing it 😄

@PterX
Copy link

PterX commented Jan 29, 2024

any update here?

@tristan957
Copy link
Contributor

Yeah... that's my bad. Let me get to it this week.

@PterX
Copy link

PterX commented Jan 30, 2024

Yeah... that's my bad. Let me get to it this week.

thx

options: cp.ExecFileOptions = { shell: true },
) {
if (extraEnv) {
options.env = { ...(options.env ?? process.env), ...extraEnv };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I don't understand the node API here, if we pass an environment object, does it not also inherit the parent environment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure. The documentation says, about the env option:

env: Environment key-value pairs. Default: process.env.

So because the default is process.env and not {}, I'd guess that options.env replaces the parent environment. (That also makes sense because otherwise, you couldn't delete environment variables.)

package.json Outdated Show resolved Hide resolved
@tristan957
Copy link
Contributor

Just a few comments, and then it should be good to go. It would also be useful if you could add an entry in the CHANGELOG.md file. Otherwise, I can get to it after merge.

package.json Outdated Show resolved Hide resolved
This setting allows setting extra environment variables during the
setup stage.
It's already possible to add environment variables in the 'options'
argument — but child_process.execFile() does not treat options.env as
extra environment variables to add. It replaces the environment with
options.env entirely. So, it's convenient to have an extraEnv argument
with variables to add.

This will be necessary for the testEnvironment setting added in the next
commit.
This setting allows setting extra environment variables while running
meson test, as well as individual tests.
Consistently replace 'Meson setup' -> 'setup' as pointed out in code
review. Improve phrasing for mesonbuild.buildFolder.
@tristan957 tristan957 merged commit b7162ce into mesonbuild:main Mar 9, 2024
6 checks passed
@ptomato ptomato deleted the 9-environment-variables branch March 9, 2024 16:41
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.

Custom environment variables for meson configuration
3 participants