Skip to content

test(path): pin realpath -s/-L/-P override precedence - #3026

Merged
chaliy merged 2 commits into
mainfrom
eve/clever-mccarthy-nlthk2
Nov 30, 2026
Merged

chaliy merged 2 commits into
mainfrom
eve/clever-mccarthy-nlthk2

Conversation

@chaliy

@chaliy chaliy commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

What changed

Pins the realpath -s / -L / -P override precedence with a regression
test, and makes the Realpath doc comment say what the combination does.

No behaviour change — this is a test plus a doc comment. The behaviour itself
landed in #3025, which regenerated the argument surface from
uutils/coreutils@2a072db29 and gave -L an overrides_with(strip).

Why

Follow-up to the review finding on #3025
(thread).
The sync changed combined-flag behaviour with nothing pinning it: path.rs
reads only the strip flag and treats -L/-P as equivalent per L-FS-001,
so the only strip coverage was -s on its own
(test_realpath_strip_keeps_symlinks). A future coreutils-args-drift regen
could drop or flip the override and no test would notice.

The precedence is also asymmetric, which makes it easy to get wrong by
inspection: -L/-P declare overrides of -s, but -s declares none of its
own, so a trailing -L/-P clears -s while a trailing -s survives them.

I could not write this test before #3025 merged — against the old surface
realpath -s -L still stripped, so the test would have encoded the old result
and broken on merge. Hence the separate PR.

Before / After

Expected values were taken from GNU coreutils 9.4 realpath on the same
layout (/l -> /a/b), and bashkit matches on all seven cases:

args output
-s /l/./c /l/c
-s -L /l/./c /a/b/c
-L -s /l/./c /l/c
-s -P /l/./c /a/b/c
-P -s /l/./c /l/c
-L /l/./c /a/b/c
-P /l/./c /a/b/c

Verified the test actually guards the surface: removing
.overrides_with(OPT_STRIP) from generated/realpath_args.rs makes it fail,
and restoring it makes it pass.

Also confirmed the generated surface is faithful to upstream — uu_app() at
2a072db29 declares overrides_with(OPT_STRIP) on -L and
overrides_with_all([OPT_STRIP, OPT_LOGICAL]) on -P, exactly as generated.

Risk

  • Low
  • Test-only plus a doc comment; no runtime path changes. If the override
    precedence is ever changed deliberately upstream, this test fails and the
    expectations need updating with a fresh GNU comparison.

Checklist

  • Tests added or updated
  • Backward compatibility considered

Generated by Claude Code


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

The coreutils args sync in #3025 gave `-L` an `overrides_with(strip)` and
left `-P` with `overrides_with_all([strip, logical])`, so a trailing
`-L`/`-P` now clears `-s` and restores symlink resolution while a trailing
`-s` survives them. Nothing pinned that: `path.rs` reads only the `strip`
flag and the sole strip test used `-s` alone, so a future
`coreutils-args-drift` regen could flip the combination silently.

Add a table-driven test over `-s`, `-s -L`, `-L -s`, `-s -P`, `-P -s`, `-L`
and `-P`, with expectations taken from GNU coreutils 9.4 on the same
layout, and note the override in the `Realpath` doc comment, which
previously said only that `-L`/`-P` are equivalent.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit d99cbb4 Commit Preview URL

Branch Preview URL
Nov 30 2026, 09:31 AM

@bashkit-pr-reviewer

bashkit-pr-reviewer Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Review summary — #3026 (test-only: realpath -s/-L/-P precedence)

Verdict: No findings. Safe to merge — test plus doc-comment only, no behaviour change.

What the change does: adds test_realpath_strip_logical_physical_override_order pinning that a trailing -L/-P clears -s (symlink resolved) while a trailing -s wins (symlink kept), and extends the Realpath doc comment to state that override explicitly.

Since the last review (aeb228e → d99cbb4): only the new test's assertion label changed — args.join(" ") instead of {args:?} to comply with no_debug_fmt_in_builtin_source (TM-INF-022). No behaviour or expectation change; strictly an improvement.

What I verified beyond the diff:

  • Read crates/bashkit/src/builtins/path.rs around the hunk (Realpath docs, strip → resolver branch, new test) — only strip reaches the resolver, so the override pair has exactly the one user-visible consequence the test pins; -L/-P equivalence claim matches L-FS-001.
  • Previously verified crates/bashkit/src/builtins/generated/realpath_args.rs (OPT_STRIP has no overrides_with; OPT_LOGICAL.overrides_with(OPT_STRIP); OPT_PHYSICAL.overrides_with_all([OPT_STRIP, OPT_LOGICAL])) — matches the test's order-dependence comment; doc hunk unchanged in this push.
  • Checked knowledge/operations/limitations.md L-FS-001 — still accurate, no knowledge update needed; no sandbox/security surface (VFS-only test helpers symlinked_dir_fs / run_realpath_with_fs).
  • Diff is complete (truncated: false); reviewed from the head snapshot at d99cbb4. Shell searches were unavailable this run (tool restarts), so verification used direct file reads plus the full diff.
  • No build/test run per project reviewer rules — reasoned from code only.

Not reviewed: behaviour itself (landed in #3025 per description).

`no_debug_fmt_in_builtin_source` (TM-INF-022) bars Rust Debug formatting
from `src/builtins`, and the new test's `{args:?}` assertion messages
tripped it in CI. Join the argument slice into a Display label instead of
suppressing the guard with `// debug-ok:`, so the assertion text stays
readable and the invariant keeps its meaning.
@chaliy
chaliy merged commit 792280b into main Nov 30, 2026
114 checks passed
@chaliy
chaliy deleted the eve/clever-mccarthy-nlthk2 branch November 30, 2026 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant