Skip to content

tests: preserve environment overrides in WASI - #15150

Merged
sylvestre merged 3 commits into
uutils:mainfrom
darkraider01:wasi-environment-overrides
Oct 7, 2026
Merged

sylvestre merged 3 commits into
uutils:mainfrom
darkraider01:wasi-environment-overrides

Conversation

@darkraider01

Copy link
Copy Markdown
Contributor

The WASI test harness forwards duplicate environment variables when a test overrides a default or sets a variable more than once. This makes overrides behave differently from native commands.

Resolve duplicates before forwarding them to the guest, keeping the last value. A regression test covers both cases on native and WASI runs.

Split out of #15139 as requested in review.

Comment thread tests/uutests/src/lib/util.rs Outdated
for (key, val) in &cmd_env {
// WASI reads the first duplicate, whereas Command::envs uses the last.
// Resolve overrides before forwarding them to the guest.
let wasm_env: BTreeMap<_, _> = cmd_env.iter().cloned().collect();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could be a map of refs, no? cmd_env.iter().map(|(k, v)| (k, v)).collect() avoids the clone

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done, thank you

@sylvestre
sylvestre merged commit 8460811 into uutils:main Oct 7, 2026
127 of 128 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

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