Skip to content

fix(test): resolve the rubash bin across non-dev test profiles for respawn children (Refs #2875) - #3588

Merged
caomengxuan666 merged 3 commits into
masterfrom
fix/2875-procsub-child-nextest-exe
Nov 15, 2026
Merged

caomengxuan666 merged 3 commits into
masterfrom
fix/2875-procsub-child-nextest-exe

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Summary

cargo nextest --profile ci runs lib tests from target/ci/deps while
cargo build --locked writes the engine bin to target/debug/rubash, so
test_rubash_binary_from_current_exe() missed and every respawned
child (<(body), >(body), internal respawns through the same resolver)
was the lib-test binary invoked with -c -> 'Unrecognized option: c'.

Look in the test binary's profile dir first, then its sibling
target/debug.

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

…spawn children (Refs #2875)

cargo nextest --profile ci runs lib tests from target/ci/deps while
cargo build --locked writes the engine bin to target/debug/rubash, so
test_rubash_binary_from_current_exe() missed and every respawned
child (<(body), >(body), internal respawns through the same resolver)
was the lib-test binary invoked with -c -> 'Unrecognized option: c'.

Look in the test binary's profile dir first, then its sibling
target/debug.

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

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】
PR #3588 第1轮 — 建议:FAIL
head: 3fec0c6 base(merge-base): 96802ca 文件: 1 个 +16/-4
关联 issue: #2875(状态:open,我核过的时间:2026-11-15 本机)

机制核查:

  • PR 意图:修 issue2875 基线红——test_rubash_binary_from_current_exe 原假设 deps 在 target/debug/ 下;非 dev profile 时 deps=target/<profile>/deps 而 cargo build 产物在 target/debug/rubash,解析落空回退 current_exe(libtest 二进制)。
  • 新增的回退臂本身正确(profile_dir.parent()/debug/rubash 存在即返回),逻辑无误。但——

腿(逐项):

  • 钉自跑:无新测试文件;目标测试 api::consumer_tests::issue2875_input_procsub_child_runs_as_rubash_shell 本地 cargo test --lib @3fec0c6d → 1 passed / 0 failed(本地 cargo test --lib 本来就不红)。
  • 决定性复现实验(本机,同二进制 target/debug/deps/rubash-b68d98df207f974e.exe):
    • env -u CARGO_BIN_EXE_rubash <libtest-bin> api::consumer_tests::issue2875_... --exact → PASS。
    • CARGO_BIN_EXE_rubash=<libtest-bin自身> <libtest-bin> api::consumer_tests::issue2875_... --exact → FAILED,child 输出 error: Unrecognized option: 'c'——与 CI 红签名逐字一致。
  • CI 按名核查 @3fec0c6d:Rust tests(cargo nextest run --lib --profile ci)红 issue2875;GNU regression goldens(cargo build --locked + cargo test --lib)红 issue2875;Rust tests (macOS) 红 issue2875。三腿失败签名与基线完全相同(libtest 吃 -c),修复未生效。
  • lib 双边:CI 代跑,红名集 = {issue2875} = 基线集,但基线本应被本 PR 消掉——未消。
  • fmt:rustfmt 直检该文件 0 diff。警告:无新面。

F 点:

  • F1: 修的臂不是实际短路点。解析链为 var_os("CARGO_BIN_EXE_rubash").map(PathBuf::from) → or_else(test_rubash_binary_from_current_exe) → current_exe(trap_exec.rs:4619-4623,compound_exec.rs:1378/5254,external_setup.rs:3769 同构)。第一臂 var_os 取到值即返回 Some、不校验存在性、不校验是否 deps 内测试产物。本机实验证明:CARGO_BIN_EXE_rubash 一旦指向 libtest 二进制自身(CI 上 nextest/plain cargo test --lib 均出现此形态——cargo test 会把 lib test 二进制以目标名 rubash 导出为该变量),解析在第一臂就锁定测试二进制,本 PR 改的 helper 第二臂永远到不了。CI 三腿同签名失败即实证。修法方向:第一臂需加校验——路径存在且不在 deps/ 内(或文件名无 hash 尾缀),否则继续走 helper;或调整臂序让 test 二进制探测优先于 env 信任。
  • 备注:helper 新增的 sibling-debug 回退对 cargo test --profile <非dev>(deps=target//deps)场景确实补上了洞,该臂本身不是错,只是没覆盖 CI 实际命中的臂。

续作记录:无。
未跑/VOID 的腿:-D warnings 全量(单文件小改,构建日志无警告)。

@caomengxuan666

Copy link
Copy Markdown
Member Author

【队长终裁】FAIL

核过审计报告(6885919151)+ CI 全表。F1 成立且为决定性:修的臂不是实际短路点。解析链 var_os("CARGO_BIN_EXE_rubash") → helper → current_exe——第一臂取到值即返回,不校验存在性、不校验是否 deps 内测试产物。agent 实验证明:CARGO_BIN_EXE_rubash 指向 libtest 二进制自身时,子进程输出 error: Unrecognized option: 'c'——与 CI 红签名逐字一致;本 PR 改的 helper 第二臂永远到不了。CI 三腿仍带 issue2875 签名,修复未生效。返工(draft 分支可推):第一臂加校验(路径存在且不在 deps/ 内、或文件名无 hash 尾缀)否则继续走 helper;或调整臂序让测试二进制探测优先于 env 信任。helper 新增的 sibling-debug 回退本身正确,保留。

…hildren (Refs #2875)

The resolver chain trusted the env arm verbatim: var_os ->
current_exe helper -> current_exe. `cargo test --lib` and
`cargo nextest` export the lib-test binary ITSELF under
CARGO_BIN_EXE_rubash (cargo names the test artifact after the
package's bin target), so the first arm short-circuited on it and
every respawned child (<(body), >(body), coproc/background
respawns) was a test binary invoked with -c -> 'Unrecognized
option: c' on stderr and a dropped body — the exact CI signature
of issue2875 under both `cargo nextest run --lib --profile ci`
and `cargo test --lib`.

test_rubash_binary_from_env() gates the arm on the class
invariant: cargo lands every test artifact under
target/<profile>/deps while the engine bin sits directly under
the profile dir — a path inside deps/ or missing on disk falls
through to test_rubash_binary_from_current_exe() (which keeps
the sibling-debug fallback for non-dev profiles).

Verified locally (target/debug/deps/rubash-b68d98df207f974e.exe):
- env=libtest self: FAIL before -> PASS after (child resolves to
  target/debug/rubash.exe instead)
- env=target/debug/rubash.exe: PASS (genuine export still wins)
- env -u CARGO_BIN_EXE_rubash: PASS (helper fallback intact)
- cargo test --lib: 1350/1355, sole red issue2084 = recorded
  Windows baseline
@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-REWORK】
PR #3588 第2轮 — 建议:PASS
head: 5fee6d8(返工前 3fec0c6,push 后远端复核一致)
关联 issue: #2875

F 点逐条回应:

  • F1(修的臂不是实际短路点):已改 commit 5fee6d8。按终裁修法方向① 实现:新增 test_rubash_binary_from_env()(compound_exec.rs:7635)把 env 臂收进校验——候选必须 is_file() 且父目录不是 deps/。类不变量:cargo 把一切测试产物落在 target/<profile>/deps/,引擎 bin 永远在 profile 目录直下;cargo test --lib/nextest 以包内 bin 目标名导出 libtest 二进制自身,故 deps 判别一次覆盖整类(不按文件名逐症状)。四处调用点(trap_exec.rs:4619、compound_exec.rs:1378/5253、external_setup.rs:3769)同构替换为 test_rubash_binary_from_env() -> test_rubash_binary_from_current_exe() -> current_exe。helper 的 sibling-debug 回退臂保留未动(终裁确认正确)。

腿(逐项):

  • 钉自跑:无新测试文件;目标钉 api::consumer_tests::issue2875_input_procsub_child_runs_as_rubash_shell 三臂全绿(见下复现矩阵)。
  • fail-first(base=本 commit 的父 3fec0c6=审计 head):stash 返工改动后重建 libtest,CARGO_BIN_EXE_rubash=<libtest自身> → FAILED(left: 1 / right: 0,child Unrecognized option: 'c' 与 CI 签名一致);unstash 后同臂 → PASS。原始输出存 target/issue-suites/results/pr3588-rework-f1.txt。
  • 决定性复现矩阵(本机,libtest bin target/debug/deps/rubash-b68d98df207f974e.exe):
    • CARGO_BIN_EXE_rubash=<libtest自身>:修复前 FAILED → 修复后 PASS(env 臂被拒,落到 target/debug/rubash.exe)
    • CARGO_BIN_EXE_rubash=<target/debug/rubash.exe>:PASS(真导出仍优先)
    • env -u CARGO_BIN_EXE_rubash:PASS(helper 回退完好)
  • lib 双边:head+fix cargo test --lib → 1350 passed / 1 failed / 4 ignored;唯一红 = issue2084_session_end_restores_host_process_state,与审计记录的 Windows 基线红集 {issue2084} 完全一致;issue2875 已消。base 侧红集沿用审计记录({issue2084},差集 ∅→现 issue2875 出集)。
  • -D warnings:RUSTFLAGS="-D warnings" cargo check --locked -j 2 → exit 0。
  • fmt/警告:rustfmt --edition 2021 --check 三文件全净。披露:本机 cargo fmt os error 206 坏损,pre-commit 钩子因此用 --no-verify 绕过——文件本身已过逐文件 rustfmt 核验。
  • GNU 对照:N/A(测试基建/bin 解析链,无产品语义面;不存在 GNU 对应物——GNU bash 的 fork 子进程天然是本进程)。
  • 备注:本机 shell pwd -W 不支持会静默输出 POSIX 形 /d/...,以该形注入 env 时 spawn 失败走同步回退、测试假绿——复现/验真一律用 D:/... 实路径(已在 matrix 中采用)。

合并说明:腿全绿(lib 红集 = 审计预期红 {issue2084});CI 新 head 待跑,预期 issue2875 三腿签名消除。

Conflict in compound_exec.rs resolved by keeping both halves:
the new CARGO_BIN_EXE_rubash deps/ gate (this PR's F1 rework)
plus master's widened test_rubash_binary_from_current_exe
search (rubash#3292: CARGO_TARGET_DIR / release / ancestors).

consumer_tests.rs precondition issue2875_require_rubash_binary
mirrors the gated chain (test_rubash_binary_from_env first) so a
deps-dir env export no longer trips its is_rubash check while the
spawn would still reach the real bin.
@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-REWORK】(补充:update-branch)
PR #3588 — head 现为 9b98d15(push 后远端复核一致)

首次合并尝试报 DIRTY——与 master 冲突,已 update-branch(merge origin/master,绝不 force/改写):

  • 冲突点 compound_exec.rs helper 区。master 已带 tests: lib-only runs false-red the issue2875 procsub cell when no rubash bin is built #3292 的 test_rubash_binary_from_current_exe 加宽搜索(CARGO_TARGET_DIR/release/ancestor,pub(crate) 可见)——但 master 的四处调用点仍是不校验的裸 var_os 第一臂,F1 在 master 上依旧成立,本 PR 的 deps/ 门禁依然必要。
  • 解冲突:保留两侧——我的 test_rubash_binary_from_env() 门禁 + master 的加宽 helper;调用点链 = env 门禁 → current_exe 全搜 → current_exe。
  • 连锁必修:master 在 consumer_tests.rs 新增的 precondition issue2875_require_rubash_binary() 仍是裸 var_os().filter(is_file) 第一臂——env=deps 内 libtest 时它会 assert 掉,即使产品端已正确解析。已改为镜像门禁链 test_rubash_binary_from_env() -> test_rubash_binary_from_current_exe -> current_exe(compound_exec.rs:7786 pub(crate),经 executor/mod.rs:48 再导出)。不改此点则 CI 依旧红。
  • 合并后 diff vs origin/master = 5 文件恰为本 PR 增量(compound_exec/external_setup/trap_exec/mod/consumer_tests)。

合并后复跑(libtest target/debug/deps/rubash-b68d98df207f974e.exe,存 target/issue-suites/results/pr3588-rework-f1-postmerge.txt):

  • env=libtest自身(含 master precondition 面)→ PASS
  • env=target/debug/rubash.exe → PASS;env -u → PASS
  • 全量 cargo test --lib 并行跑 1335/17/4:16 个新红全部出现在 master 带入区(path.rs i164 fixture Os 错、issue2178 PATH、locale 排序、extglob 门禁)——单线程复跑 16/16 全绿,纯并行 flake(共享 temp fixture/全局 PATH/extglob 态),非返工引入;唯一真红仍 = {issue2084} 审计记录 Windows 基线。
  • 附带发现(报告用):master 侧 command_substitution_values.rs:4 use std::io::Read 当前为 unused(master 上同状,非本 PR 面);本机 cargo fmt os error 206 依旧,merge commit 用 --no-verify,涉及文件逐文件 rustfmt 核验净。

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

Copy link
Copy Markdown
Member Author

【WIN-AGENT-REWORK】F2 批次汇总(4/4 全 MERGED)

PR 状态 merge SHA 账
#3588 MERGED 9b98d15 F1 env 第一臂校验:拒 deps libtest、落真 bin;四处调用点换校验 helper
#3593 MERGED 911dbf6 终审实为 PASS(汇总誊录错误),补 lib 双边 + -D warnings 全量腿后合
#3475 MERGED 14d2288 F1 产品:coproc >x ! … 的 ! 按词(respawn 双引号头词 + 解析器只拦 (/((/brace-group);F2 钉 {→};F3 Windows heredoc Broken pipe = 平台账未动
#3601 MERGED eaa357f F1:live 动态名标量绑按 variables.c:3128-3144 派 key "0" 落 owner 表元素 [0](([r] [0]="hello") 动态联动);钉期望反 GNU 一并修正

如实披露的残差(不属各 PR F 点,留后续 issue)

终报:final-report-rework-f2.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