Repository navigation
fix(test): hold the CLI env lock in every CLI parsing test - #3579
Merged
Merged
Conversation
inureyes
added a commit
that referenced
this pull request
Nov 30, 2026
clap reads MLXCEL_* env defaults at parse time, and the ScopedEnv tests in src/main_tests.rs set those variables process-wide while holding CLI_ENV_LOCK. 48 tests parsed the CLI without the lock, so under the default parallel test runner they could see another test's value. On GB10, settings_cli_mlxcel_serve_defaults_off_and_explicit_flag_enables failed once because serve_responses_background_ephemeral_ttl_zero_is_refused (#2915) had MLXCEL_RESPONSES_BACKGROUND_EPHEMERAL_TTL_SECS=0 set. Every CLI parsing test now takes a shared cli_env_lock() helper, which also recovers from a poisoned lock so one failing test no longer fails the other lock holders. The 11 existing lock sites use the same helper. A new scan test, every_cli_parsing_test_holds_the_env_lock, fails when a test that parses the CLI (directly or through a helper in the file) does not take the lock. Validation: removing the lock from one test makes the scan test fail and name it; cargo test --bin mlxcel passed 10 of 10 consecutive default-parallel runs (365 passed); clippy with -D warnings and fmt are clean.
inureyes
force-pushed
the
fix/cli-tests-env-lock
branch
from
November 30, 2026 02:27
496e253 to
42a3eef
Compare
inureyes
marked this pull request as ready for review
November 30, 2026 02:27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
clap reads
MLXCEL_*env defaults at parse time, and theScopedEnvtests insrc/main_tests.rsset those variables process-wide while holdingCLI_ENV_LOCK. 48 tests parsed the CLI without the lock, so under the default parallel runner they could observe another test's value. During the auto-impl run for #3567 to #3569,settings_cli_mlxcel_serve_defaults_off_and_explicit_flag_enablesfailed once on GB10 with0 is not in 1..becauseserve_responses_background_ephemeral_ttl_zero_is_refused(added in #2915) hadMLXCEL_RESPONSES_BACKGROUND_EPHEMERAL_TTL_SECS=0set at the same moment.Changes
cli_env_lock()helper. The helper recovers from a poisoned lock, so one failing test no longer fails every other lock holder. The 11 existing lock sites use it too.every_cli_parsing_test_holds_the_env_lockreadsmain_tests.rsand fails when a#[test]that parses the CLI, directly or through a helper in the file, does not take the lock.Validation
cargo test --profile test-fast --features cuda --bin mlxcel: 10 of 10 consecutive default-parallel runs passed (365 passed).cargo clippy --features cuda --bin mlxcel --tests -- -D warnings,cargo fmt --checkand the fourscripts/cicontract checks pass.