Repository navigation
mock_command: add new_command_with_env so compiler children get only the client environment - #3016
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3016 +/- ##
==========================================
+ Coverage 79.99% 80.02% +0.02%
==========================================
Files 76 76
Lines 47374 47413 +39
==========================================
+ Hits 37898 37942 +44
+ Misses 9476 9471 -5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
sorry but it needs to be rebased |
| dead_code, | ||
| reason = "Read in the async_trait below, but rustc doesn't see it as used" | ||
| )] | ||
| Inspect(Box<dyn Fn(&MockCommand) -> Result<MockChild> + Send>), |
There was a problem hiding this comment.
could Call just take the &MockCommand instead of adding a second variant? it is almost the same thing
There was a problem hiding this comment.
Yeah, good call. Call now takes &MockCommand, and next_command_calls just forwards &cmd.args so the existing callers didn't need to change.
|
|
||
| #[test] | ||
| #[cfg(unix)] | ||
| fn test_single_compile_command_uses_only_client_env() { |
There was a problem hiding this comment.
this is almost the same test as test_new_command_with_env_hides_server_env in mock_command.rs, do we need both?
There was a problem hiding this comment.
No, dropped the one in mock_command.rs. This one is more useful since it actually goes through a call site. Also rebased on main.
d41ba8d to
e1087b8
Compare
Every compiler invocation had to remember to call env_clear() before envs(), and forgetting it silently leaks the server's environment into the compiler. new_command_with_env does both, and all the call sites that pass the client's environment now go through it. The few places that deliberately layer onto the server environment (direct client compile, compiler/assembler detection) are left alone. MockCommand now records env, env_clear and current_dir so tests can see what a command would have run with. Fixes mozilla#95 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
MockCommandCreator::next_command_inspects lets a test see the whole command, not just its arguments. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
e1087b8 to
013cf41
Compare
|
Thanks for your PR |
Every compiler invocation had to remember to call
env_clear()beforeenvs(env_vars). Forgetting it leaks the server's environment into the compiler without any error.This adds
CommandCreatorSync::new_command_with_env, which does both, and moves every call site that passes the client environment over to it. The client's direct compile and compiler/assembler detection are left alone, since they deliberately build on the inherited environment.MockCommandnow records env,env_clearandcurrent_dirinstead of ignoring them.next_command_inspectslets a test see the whole command. There are new tests forSingleCompileCommand::executeand gcc preprocessing. I checked that both fail if theenv_clearis removed.Fixes #95
Locally, fmt and the lib tests pass. Clippy fails on rustc 1.99 with pre-existing lints, and does the same on main.
tests/sccache_cargo.rsfails intermittently both with and without this change.