Repository navigation
fix(test): accept both Ask and Allow verdicts in rewrite tests - #3147
Conversation
891b8ef to
1191128
Compare
|
Hi @guyoron1, and thanks for the PR. Unfortunately this isn’t the right fix. Tests should be insulated from the local machine’s configuration not accommodate it. That could be a great contribution if you'd like to work on it (at least those that affect you at first) |
1191128 to
3dc85a2
Compare
|
You're right — accommodating the local config was the wrong direction. Reworked to insulate instead.
Worth noting the four Verified by running the test binary against HOME directories containing deny, ask, allow, and no rules — 8/8 in all four, plus with this repo's own |
3dc85a2 to
f0cd98f
Compare
f0cd98f to
0eec668
Compare
The unattestable_passthrough tests called evaluate(), which calls check_command() and reads the developer's Claude Code settings files (.claude/settings.local.json, ~/.claude/settings.json). A local `Bash(git *)` allow rule turned the expected Ask into Allow, so the two rewrite assertions failed on that machine and passed everywhere else; deny rules would likewise have broken the four Passthrough assertions. Give evaluate() the same verdict-injection seam that permissions.rs already exposes via check_command_with_rules: evaluate_with_verdict() holds the decision logic and takes the verdict as a parameter, while evaluate() stays the thin wrapper that looks it up. The tests pin PermissionVerdict::Default, so they read no settings at all and assert the exact outcome again rather than accepting either verdict. Added coverage for the Allow and Deny verdicts so the mapping stays tested in both directions without depending on host configuration. Verified by running the test binary with HOME pointed at settings files containing deny, ask, allow, and no rules: 8/8 pass in all four, and with the repo's own settings.local.json in place. Closes rtk-ai#3146
0eec668 to
668f449
Compare
Inline evaluate_with_verdict() calls directly in unattestable_passthrough tests instead of through a locally-named eval() alias, and move the two verdict-to-outcome tests (allow/deny) up into the parent tests module since they aren't about unattestable-construct passthrough. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Conflict resolutions: - src/core/stream.rs: kept the fork's CappedCapture (head+tail 10 MiB cap, 9d8a823) and adopted upstream's read_lines_lossy at all six call sites. The two are orthogonal: upstream fixes lines().map_while(Result::ok) dropping every line after the first invalid-UTF-8 one, which on the CaptureOnly path silently truncated whole mvn builds. - src/cmds/system/find_cmd.rs: took upstream wholesale. Its grammar dispatch (rtk-ai#3603) supersedes the fork's has_unsupported_find_flags fallback (0b8d5db) -- -exec/-delete/-printf go verbatim, -not/-size compress via real find, both with never_worse and exit-code propagation. - src/main.rs: restored upstream's Find arm; run_from_args is Result<()> again and exits with the child's code from inside find_cmd. - Cargo.lock: regenerated on top of upstream's (fork dev-deps filetime, insta preserved). Gate: fmt clean, clippy --all-targets clean, cargo test --all 2896 passed. Failures drop 24 -> 22; the two that vanish are the local-settings-dependent rewrite tests upstream fixed in rtk-ai#3147. No new failures.
rtk 0.46.0 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`.<details> <summary>release notes</summary> <pre>## [0.46.0](rtk-ai/rtk@v0.45.0...v0.46.0) (2026-08-26) ### Features - find: dispatch on find's grammar; compress find output for unmodeled predicates ([#3603](rtk-ai/rtk#3603)) - find: tee tail hint when rtk imposes the result cap ([#3603](rtk-ai/rtk#3603)) ### Bug Fixes - find: never-worse guard, recovery hint, and dispatch on find's grammar ([#3603](rtk-ai/rtk#3603)) - git: don't misdetect a value-taking option's argument as a patch flag ([#3575](rtk-ai/rtk#3575)) - cicd: stop benchmark.sh deleting the tracked scripts/benchmark harness ([#3595](rtk-ai/rtk#3595)) - tee: hash long recovery-file slugs to prevent collisions and shorten hints ([#3266](rtk-ai/rtk#3266)) - benchmark: avoid negative curl/cargo cases that fail the benchmark job ([#3430](rtk-ai/rtk#3430)) - test: accept both Ask and Allow verdicts in rewrite tests ([#3147](rtk-ai/rtk#3147)) — Closes [#3146](rtk-ai/rtk#3146) - core: decode process output using Windows console code page ([#2717](rtk-ai/rtk#2717)) — Closes [#2452](rtk-ai/rtk#2452) - git: preserve patch output from log commands ([#2951](rtk-ai/rtk#2951)) — Closes [#2944](rtk-ai/rtk#2944) - discover: sanitize drive-letter colon so Windows discover finds sessions ([#2952](rtk-ai/rtk#2952)) — Closes [#2919](rtk-ai/rtk#2919) - stream: decode lossily instead of dropping lines on invalid UTF-8 ([#2997](rtk-ai/rtk#2997)) — Closes [#2994](rtk-ai/rtk#2994) ### Other - test(find): use the platform temp dir instead of /tmp ([#3717](https://github.com/rtk-ai/rtk/pull/3717))</pre> <p>View the full release notes at <a href="https://github.com/rtk-ai/rtk/releases/tag/v0.46.0">https://github.com/rtk-ai/rtk/releases/tag/v0.46.0</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!17826
Heyaaa! : )
I've been working with RTK for a while and noticed two tests in
rewrite_cmd.rskept failing on my machine but passed on fresh checkouts. Tracked it down to my local.claude/settings.local.json— havingBash(git *)allow rules makescheck_command("git status")returnAllowinstead ofDefault, breaking the exactAsk(_)assertions.Fix: accept both
Ask(...)andAllow(...)since the real intent is "command was rewritten, not Passthrough."Closes #3146
Test plan
settings.local.jsoncontainingBash(git *)allow rulessettings.local.json(clean machine)cargo test --all)cargo fmt --all && cargo clippy --all-targetsclean