Repository navigation
refactor(core): one canonical parser for boolean env flags - #1804
Merged
Merged
Conversation
fbuild answered "is this FBUILD_* flag on?" three different ways with observably different results for the same value: - fbuild-cli `is_truthy_env` treated everything but "", "0" and "false" as true, so `=no`, `=off` and `=-1` *enabled* features. - fbuild-paths `env_flag_is_one` accepted only "1", so `=true` and `=yes` were off. - daemon `refresh_emu_cache_requested` accepted 1/true/TRUE/yes/YES but not `True` or `on`. Add `fbuild_core::env_flag` with one documented truth table -- on: 1/true/yes/on, off: unset/""/0/false/no/off, unrecognised: off -- and route the four copies through it. Unrecognised input is deliberately off so a typo can never silently enable a feature. Not migrated, by design: FBUILD_DEV_MODE keeps its literal-`1` contract (#1349: a stray `=0` used to select the dev tree), and the CI-marker helper in windows_long_paths.rs is untouched. Widening those is a separate decision, not a mechanical move.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
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.
Closes #1798 as "unify", with one documented truth table.
The conflict, and the fix
=no=truefbuild-cli/update_check.rs::is_truthy_envfbuild-paths/running_process.rs::env_flag_is_onefbuild-daemon/…/avr8js_npm.rs::refresh_emu_cache_requestedTrue: off)fbuild-packages-fetch/…/downloader_mirrors.rs::mirror_first_requestedNew
fbuild_core::env_flag(all four crates already depend on it):parse(&str) -> Option<bool>— pure, tested without touching the process env.is_set(name) -> bool— the one call every flag uses.Truth table (value trimmed, ASCII case-insensitive): on =
1,true,yes,on; off = unset,"",0,false,no,off; anything else =off. The last rule is the important one: a typo (
ture,-1,2) must neversilently enable a feature.
=no/=offare now genuinely off everywhere, and=true/=yesare now genuinely on everywhere.Deliberately not migrated
FBUILD_DEV_MODE(4 copies infbuild-paths,fbuild-core::response_file,fbuild-cli::dispatch). Its literal-1-only contract is deliberate(dylint: ban raw
.fbuildpath literals outside fbuild-paths; ratchet to zero #1349:var_os(..).is_some()made=0select the dev tree). Widening itwould relocate the cache root for anyone with
FBUILD_DEV_MODE=truein theenvironment — an owner decision, tracked on the issue, not a mechanical move.
windows_long_paths.rs's CI-marker check (same broad rule as the oldis_truthy_env) — separate cleanup.port_doctor's sysfscontrolparser andcdc.rs's-DARDUINO_USB_CDC_ON_BOOTparser: those read kernel/compiler values, not env vars, and their current
comments document why unknown input is "no data", not false.
Tests (real output)
soldr cargo test -p fbuild-core --lib env_flag→ 5 passed, 0 failed(truthy set, falsy set, padding, malformed-never-on,
is_setthrough adedicated env name).
soldr cargo test -p fbuild-cli --bin fbuild canonical_env_flag→ 1 passed(
suppress_from_envover 1/true/on/Yes/0/no/off/ture/"").soldr cargo test -p fbuild-paths --lib→ 92 passed, 0 failed, 1 ignored.soldr cargo test -p fbuild-daemon --lib npm_cache→ 10 passed, 0 failed.soldr cargo test -p fbuild-packages-fetch --lib mirror_first_env→ 1 passed.bash test(TMPDIR=/home/niteris/t) → 4044 passed / 0 failed / 109 ignored, rc 0.soldr cargo fmt --checkrc 0;SOLDR_VERDICTS=off soldr cargo clippy --workspace --all-targets -- -D warningsrc 0;boundary
44/43rc 0;ci/check_test_layout.pyok.Note: the new
update_checktest and the existingci_detection_via_ci_envtest bothmutate CI markers, so they now share a
Mutexguard; previously they raced onseparate test threads.
Local
ci.run_dylintis not usable on this host (nightly driver/rustc drift); thehosted Dylint lanes on this PR are the evidence.