Repository navigation
feat(cli): add fbuild doctor --check-disk (#1750 item 5) - #1770
Merged
Merged
Conversation
`doctor` reports, without building, the free space of every root a cold ESP32 build writes plus the bytes the cache root could give back. It reuses `fbuild_build_engine::disk_preflight` (the same FreeSpace seam, requirement constants and reclaimable-cache walk a build uses), so the numbers and the failure wording cannot drift from what the build acts on. The exit code carries the verdict; an unmeasurable volume is a printed line, never a failure, and FBUILD_MIN_DISK_BYTES=0 prints `skipped`. `disk_preflight::measure` now measures the nearest existing ancestor for a root that does not exist yet: a fresh host has no `<cache>/tmp`, so the scratch root used to report `could not be measured` on every fresh machine. Only NotFound walks up — permission/I-O errors stay unmeasurable. RED-first: forcing the `is_sufficient()` branch makes the two shortfall tests fail. 8 CLI tests + 3 engine tests; `bash test` 47 suites, 3898 passed.
|
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.
fbuild doctor --check-disk— report disk space before a build failsItem 5 of #1750 ("Optional:
fbuild doctor/--check-disk— print per-root free space and reclaimable totals without building").Why
#1767 added the ESP32 pre-flight (#1750 item 2) and #1768 translated a mid-build
ENOSPC(item 4), but both only speak when a build runs. A user on a nearly full host — or CI deciding whether to bother — had no way to ask "will this fit?" without starting a build, and no view of how many bytes the caches could give back.What
fbuild doctor [--check-disk] [PROJECT_DIR]— read-only, in-process, no daemon:<cache>/tmpscratch) throughfbuild_build_engine::disk_preflight::measure, i.e. the sameFreeSpaceseam, the same required byte counts (disk_requirements::disk_roots) and the same reclaimable-cache walk a real build uses;free / requiredwith anok (N margin)orSHORT by Nverdict;PreflightReport::failure_messageverbatim when something is short, so the text a doctor prints is the text the build would have failed with;FBUILD_MIN_DISK_BYTES=0printsskippedinstead of walking the cache;--check-diskis currently the only check, so barefbuild doctorruns it too.No build behavior changes: nothing new is enforced during a build, no cache is evicted, and
disk_preflight/disk_requirementskeep their existing semantics. Two edits outside the new files:pub mod disk_requirements;(was private) so the CLI reads the same requirement constants instead of duplicating them.disk_preflight::measurenow measures the nearest existing ancestor when a root's path does not exist yet. The first E2E run ofdoctorsurfaced it: a fresh host has no<cache>/tmp, so the scratch root reportedcould not be measuredon every fresh machine (the same false warning the build pre-flight emitted). OnlyNotFoundwalks up — a permission or I/O error is still an unmeasurable root, so a genuinely unreadable volume is still reported as such. A not-yet-created root is on a real volume, and its requirement (64 MB scratch) is a subset of the cache root's 2 GB on the same volume, so no build that passed before can now fail.Tests
crates/fbuild-cli/src/cli/doctor_tests.rs(8 tests, injected volumes — never this host's real free space): roomy report, shortfall arithmetic and failure text, only-the-short-root flagged, unmeasurable-is-a-warning, reclaimable ordering + total, empty cache root, disabled check, project-dir absolutisation.Plus 3 engine tests for the ancestor walk (
a_root_that_does_not_exist_yet_is_measured_on_its_volume,a_root_nested_under_missing_dirs_walks_to_the_first_existing_ancestor,a_permission_error_is_still_unmeasurable_and_never_walks_up).RED-first evidence: disabling the
is_sufficient()branch (forcingok) makesa_short_root_names_the_shortfall_and_failsandonly_the_short_root_is_flaggedfail; restoring it is green.Real E2E (locally built CLI, no daemon)
Gates run locally
Refs #1750 (items 3 — on-demand reclaim — and 5 is this PR; the issue stays open for item 3).