fix(cli): suppress passive cache hint under --quiet#380
Merged
Conversation
The passive "your cache is big, consider pruning" hint is emitted before clap parses argv, and only checked TOOLR_NO_CACHE_HINT, `__complete`, and `self cache …`. It never honoured `--quiet`, so the hint leaked to stderr even under `--quiet` once the cache accumulated enough orphans to trip the threshold. That broke the "`--quiet` must be silent" contract the mise enter-hook depends on: `toolr project venv sync --quiet` runs on every `cd` and must stay silent in non-toolr directories regardless of cache state. Add an argv scan for `--quiet` / `-q` (stopping at the `--` separator so a wrapped command's own `--quiet` doesn't count) and gate the hint on it. Covered by unit tests for the scanner and integration tests that build a dirty cache and assert the hint fires without `--quiet` and is suppressed with it.
Owner
Author
|
This change is part of the following stack: Change managed by git-spice. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #380 +/- ##
=====================================
Coverage 93.8% 93.8%
=====================================
Files 96 96
Lines 16023 16063 +40
Branches 118 118
=====================================
+ Hits 15041 15081 +40
Misses 972 972
Partials 10 10
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
Problem
The passive "your cache is big, consider pruning" hint (
crates/toolr/src/main.rs,maybe_emit_cache_hint_from_argv) runs before clap parses argv and was suppressed only forTOOLR_NO_CACHE_HINT, tab-completion, andself cache …. It never honoured--quiet.--quietpromises to "suppress non-error output", and the hint is non-error output — so under--quietit leaked to stderr anyway, once the cache accumulated enough orphans to trip the threshold. That breaks the "--quietmust be silent" contract the mise enter-hook depends on:toolr project venv sync --quietruns on everycdand must stay silent in non-toolr directories regardless of cache state.It surfaced as a flaky-looking failure of
project_venv_sync::sync_quiet_silently_exits_when_not_a_toolr_repo— but only on a developer machine whose real cache had crossed the orphan threshold (CI's cache is clean, so CI never saw it). The test was right; the product was wrong.Fix
Scan argv for
--quiet/-qand gate the hint on it. The scan stops at the--separator so a wrapped command's own quiet flag (toolr project venv run -- pytest --quiet) is never mistaken for toolr's, and it matches short clusters (-dq) as well as the long form.Tests
argv_requests_quiet): long/short/cluster detection, absence, and the---separator boundary in both directions.tests/cache_hint_quiet.rs): builds a dirty cache (12 orphans), asserts the hint fires without--quiet(so the suppression test can't pass vacuously) and is suppressed with it.Verification
Full
mise run testumbrella passes against a real dirty local cache with noXDG_CACHE_HOMEisolation — 382 passed, 8 skipped — proving the fix makes the suite robust to cache state, not just the isolated case.cargo clippyclean.Independent of #379 (deps upgrade); branches off
main.