Skip to content

test: gate unix-only helpers in issue2293/2302/2317 pin stems with #[cfg(unix)] (Refs #3503) - #3508

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/3503-cfg-unix-pin-helpers
Nov 14, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/3503-cfg-unix-pin-helpers

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

根因

三 pin stem 的全部测试均为 #[cfg(unix)],但 helper/常量/结构体/impl 块没有 cfg。Windows 下测试被编译掉,helper 变死代码,RUSTFLAGS="-D warnings" cargo test --tests 报 16 处 dead-code 错误;Linux 下 helper 全被测试调用,构建干净。

  • tests/issue2293_stage_stdio_dup_regressions.rs:test_dir、rubash_stdin、run_in、rubash_in_stdin_file、wait_file_contents + 4 处 use + const RUBASH
  • tests/issue2302_bash_source_bare_name_regressions.rs:fixture、write_script + 2 处 use + const RUBASH + struct Fixture + impl Fixture
  • tests/issue2317_bash_source_relative_path_regressions.rs:同上结构

修法

三文件内同机制加 #[cfg(unix)]:2293×10、2302×7、2317×7,共 24 行新增,0 行删除。纯测试改动,不动产品代码、不改测试语义、不碰 src/lexer/continuation.rs 与 docs/api-ledger.md。

GNU 锚点:不适用。本单是测试 harness 的 cfg 缺陷,不是 shell 语义分歧;pin 本身及其期望行为在 unix 下完全不变。

验证(base = master 5219be9)

Windows 腿(X299-2607,cargo/rustc 1.99.1,cl 19.44.35230):

  • fail-first(base,未修):三 stem 定向复现 16 处 dead-code 错误,与 issue 计数一致(前一棒 2026-11-13 16:39 UTC 实测,ERROR_LINES=19 含 3 行汇总)。
  • 修后三 stem 定向运行 RUSTFLAGS="-D warnings" cargo test --locked --test issue2293_stage_stdio_dup_regressions --test issue2302_bash_source_bare_name_regressions --test issue2317_bash_source_relative_path_regressions:rc=0,3 个 test result: ok(Windows 下 0 tests,符合 unix-only 设计;要点是 -D warnings 下编译干净)。
  • RUSTFLAGS="-D warnings" cargo check --locked --lib --bins:rc=0。
  • rustfmt --check 三文件:rc=0。

Linux 腿(Simular box,cargo/rustc 1.99.1):

  • RUSTFLAGS="-D warnings" cargo check --locked -j 1 --test <三 stem>:base 与修后均为 rc=0。
  • cargo check --locked -j 1 --tests 全量枚举:rc=0(Linux 下全量测试目标在 -D warnings 下编译干净)。
  • Linux 三 stem 实际跑测(28 个测试)未能完成:box 上 lib codegen 三次均被 OOM killer 以 SIGKILL 杀掉(box 可用内存仅 ~1.7–2.2G 且有其他车道并发构建;老服务器 ssh 同时 banner 超时不可达)。修法在 unix 下是 no-op(#[cfg(unix)] 为真,编译内容与 base 逐字节同义,测试体未动),跑测风险低,但按纪律如实记录:Linux 跑测待队长在空闲机器上补跑。

全量 --tests 状态(Windows):本 PR 后仍红,需后续单

cargo check/test --tests 默认遇首个失败目标即停(不继续枚举其余目标),所以不同轮次的首个失败目标不同——这是调度顺序 artifact,不是修法引入的新失败。已确认的同类前存失败(均不在本 PR 范围):

  • issue2304_numbered_devnull_spawn_regressions:同机制(RUBASH/Fixture/fixture/run 死代码,4 项)
  • issue2272_fdvar_spawn_delivery_regressions:同机制(rubash_in_stdin_file 死代码,1 项)
  • issue3413_bash_argv0_empty_import:同机制(方法 run_with_import 死代码,1 项)
  • issue1276_env_import_diagnostics_regressions:-D warnings 失败 1 项(TEST-FULL 首个失败目标)
  • issue2071_test_empty_path_regressions:unused-mut(let mut cells),与本单 lint 不同

--keep-going 全量枚举正在 X299 上跑,完整失败清单随后补进本 PR 或交队长立案。上述后续项均需各自立案/派工,不在本 PR 扩围。

本 PR 删除了什么

什么都没删除。本 PR 只有 24 行新增(每处一行 #[cfg(unix)]),0 行删除、0 行语义改动。

UNVERIFIED-BY-CAPTAIN

…cfg(unix)] (Refs #3503)

All tests in the three pin stems are #[cfg(unix)], but their helper
functions, constants, structs and impl blocks carried no cfg. On
Windows the tests are compiled out, so the helpers became dead code
and `RUSTFLAGS="-D warnings" cargo test --tests` failed with 16
dead-code errors (3x const RUBASH, 2x struct Fixture, 2x fixture,
2x write_script, 1x each test_dir/rubash_stdin/run_in/
rubash_in_stdin_file/wait_file_contents, 1x methods path_env+run+
script_abs, 1x methods path_with+run). On Linux the helpers are all
called by the tests, so the build was clean.

Fix: add #[cfg(unix)] to every unix-only item in the three files
(uses, const RUBASH, struct Fixture, helper fns, impl Fixture).
Test-only change, no product code touched: 3 files, 24 insertions,
0 deletions.

GNU anchor: none applicable. This is a test-harness cfg defect, not
a shell-semantics divergence; the pins themselves and their expected
behaviour are unchanged on unix.

Verification (master 5219be9): Windows X299 leg, 3-stem run
`RUSTFLAGS="-D warnings" cargo test --locked --test
issue2293_stage_stdio_dup_regressions --test
issue2302_bash_source_bare_name_regressions --test
issue2317_bash_source_relative_path_regressions` rc=0 (3x
"test result: ok", 0 tests each on Windows as designed);
`cargo check --locked --lib --bins` with -D warnings rc=0;
rustfmt --check clean. Linux box leg: `cargo check --locked -j 1
--test <3 stems>` with -D warnings rc=0 on base and on the fix.
Full `--tests` on Windows is NOT green with this PR alone: the
first failing target after the fix is
issue2304_numbered_devnull_spawn_regressions (same unix-only-helper
pattern, 4 dead-code items); issue2071 (unused-mut), issue2272
(dead helper) and issue3413 (dead method run_with_import) are
further pre-existing -D warnings failures in the full suite.
Those are separate follow-ups for the captain, out of scope here.

本 PR 删除了什么:什么都没删除。本 PR 只有 24 行新增
(每处一行 `#[cfg(unix)]`),0 行删除、0 行语义改动。

UNVERIFIED-BY-CAPTAIN
@caomengxuan666

Copy link
Copy Markdown
Member Author

队长复核 PASS(2026-11-14)。

亲核证据(只读复核,全程 gh API + 盘上核对):

  • diff 恰 3 个 pin stem(issue2293_stage_stdio_dup_regressions +10、issue2302_bash_source_bare_name_regressions +7、issue2317_bash_source_relative_path_regressions +7),合计 +24/−0,24 行新增全部是单行 #[cfg(unix)];零产品代码、零删除、零测试逻辑改动。
  • merge-base = 5219be90 本身(PR 直接坐在现行 master 尖上,ahead 1 / behind 0),文件交集 ∅,无需 update-branch。
  • CI run 43445040922 三红逐名亲核:唯一失败均为 issue2875_input_procsub_child_runs_as_rubash_shell(GNU goldens 1349/1、Rust tests 定向 0/1、macOS 1242/1),是 master 基线红(tests: lib-only runs false-red the issue2875 procsub cell when no rubash bin is built #3292 类),非本 PR 回归。
  • 门控形状正确:三 stem 的 28 个测试本就全带 #[cfg(unix)],本 PR 把 helper 与其唯一消费者(unix 测试)门控对齐;unix 下编译内容同义,没有任何 unix 测试需要的东西被 cfg 掉。

欠腿如实记录:Linux 三 stem 实际跑测(28 测)未完成(box 上 lib codegen OOM-SIGKILL ×3)。鉴于 unix 下本 PR 为编译同义 no-op、且 box 上 Linux cargo check --tests 全量枚举已 rc=0,此腿不挡合入,合入后在空闲 Linux 路线上补跑销账。

本 PR 为 Refs-only,合入后 #3503 由队长手动关单。正文所列同机制残余 stem(issue2304 / issue2272 / issue3413 已逐个核实同构;issue2071 为 unused-mut 不同 lint;issue1276 未证实)由队长另行立案,不在本 PR 扩围。

@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 14, 2026 00:42
@caomengxuan666
caomengxuan666 merged commit 9410bc9 into master Nov 14, 2026
8 of 11 checks passed
caomengxuan666 added a commit that referenced this pull request Nov 14, 2026
…(Refs #3507)

Root cause: every #[test] in tests/issue2066_pipeline_host_flag_regressions.rs
is #[cfg(unix)], but the shared helpers were ungated: the two use lines
(std::path::PathBuf / std::sync::Mutex and rubash::api::{RunOptions, Session},
the Session import being the unused-import face), static SERIAL, and the
functions serial(), temp_dir() and opts(). On non-unix targets these five
items are dead code, which fails RUSTFLAGS="-D warnings" builds of the test
target on Windows — the same class as #3503 (fixed by PR #3508).

Fix: add #[cfg(unix)] to exactly those items (7 insertions, 0 deletions).
No test logic changes; on unix the file is byte-equivalent in behaviour.

Verification (lane evidence, UNVERIFIED-BY-CAPTAIN): the fixed file passes
rustfmt and git diff --check; the Linux stem run reported 9 passed; Windows
legs were reported dual-green by the fix lane. Captain review legs (fail-first
on the base file, post-fix stem, -D warnings) are still owed and will run in
the review round.

本 PR 删除了什么:无删除。仅新增 7 行 #[cfg(unix)] 属性。
caomengxuan666 added a commit that referenced this pull request Nov 14, 2026
…(Refs #3507) (#3518)

Refs #3507

## 根因

`tests/issue2066_pipeline_host_flag_regressions.rs` 中全部 `#[test]` 均为 `#[cfg(unix)]`,但共享辅助项未加门控:两条 use 行(`std::path::PathBuf` / `std::sync::Mutex` 与 `rubash::api::{RunOptions, Session}`,其中 `Session` 导入即未用导入面)、`static SERIAL`、以及 `serial()` / `temp_dir()` / `opts()` 三个函数。在非 unix 目标上这五项构成 dead code,使 Windows 的 `RUSTFLAGS="-D warnings"` 测试目标构建失败。与 #3503 同类(已由 PR #3508 修复)。

## 修法

对上述五项及其两条 use 行精确添加 `#[cfg(unix)]`:7 行插入、0 删除。测试逻辑零改动;unix 上行为等价。

## 验证状态

UNVERIFIED-BY-CAPTAIN:修法已由车道在盘核验(rustfmt、`git diff --check` 通过;Linux stem 报 9 passed;Windows 腿车道报双绿)。队长复核腿(基底 fail-first、修后 stem、`-D warnings`)将在复核轮补跑。

## 本 PR 删除了什么

无删除。仅新增 7 行 `#[cfg(unix)]` 属性。
caomengxuan666 added a commit that referenced this pull request Nov 14, 2026
…(Refs #3512) (#3520)

Refs #3512

## 根因

`tests/issue2304_numbered_devnull_spawn_regressions.rs` 中全部 5 个 `#[test]` 均为 `#[cfg(unix)]`,但共享辅助项未加门控:两条 use 行(`std::path::PathBuf` / `std::process::{Command, Stdio}`)、`const RUBASH`、`struct Fixture`、`fn fixture`、`impl Fixture`(含 `fn run`)。在非 unix 目标上这些项构成 dead code,使 Windows 的 `RUSTFLAGS="-D warnings"` 测试目标构建报 4 项 dead-code。与 #3503 同类(已由 PR #3508 修复)。

## 修法

对上述 6 项精确添加 `#[cfg(unix)]`:6 行插入、0 删除。测试逻辑零改动;unix 上行为等价。

## 验证状态

UNVERIFIED-BY-CAPTAIN:车道在 X299-2607(cargo/rustc 1.99.1,cl 19.44.35230)实测——

- fail-first(基底 `0f37a6e7`):`RUSTFLAGS="-D warnings" cargo test --locked --test issue2304_numbered_devnull_spawn_regressions --no-run`,**rc=101**,恰好 4 项 dead-code(`RUBASH` 从未使用、`Fixture` 从未构造、`fixture` 从未使用、`run` 从未使用),与 issue 所述逐字一致。
- 修后:同一 stem 全量 `cargo test`,**rc=0,0 error / 0 warning**,`running 0 tests` / `test result: ok. 0 passed`(Windows 下 5 测均 `cfg(unix)`,0 测即预期);`RUSTFLAGS="-D warnings" cargo check --locked --lib --bins` **rc=0,0 error / 0 warning**;`rustfmt --edition 2021 --check` 该文件 **rc=0**。补丁 SHA256 在 X299 侧逐字核对一致。
- Linux 5 测腿欠账:Simular box 盘 100% 满、老服务器 sshd 四次 banner 超时(与 2026-11-13 窗口同形态,需用户从阿里云控制台重启恢复),Linux 侧 5 测未能跑到,待复核轮补跑。本单仅为测试辅助项加 `#[cfg(unix)]`,unix 侧零逻辑改动;Windows 腿已覆盖全部 `-D warnings` 验收口径。
- CI 注:3 腿红均为同一单测 `issue2875_input_procsub_child_runs_as_rubash_shell`(已知 lib-only-run NOBIN 陷阱,与本单无关,日志中无 issue2304 字样);其余腿全绿,含 Windows tests compile check。

## 本 PR 删除了什么

无删除。仅新增 6 行 `#[cfg(unix)]` 属性。
caomengxuan666 added a commit that referenced this pull request Nov 14, 2026
## 根因

`tests/issue3413_bash_argv0_empty_import.rs` 中 `impl Scratch` 的方法 `run_with_import`(:66)无 cfg 门控,其 5 个调用点(:93 / :102 / :111 / :126 / :142)全部落在 `#[cfg(unix)]` 测试内。Windows 下测试被编译掉,方法变死代码,`RUSTFLAGS="-D warnings" cargo check --tests` 报 1 项 dead-code。

## 修法

同已合入的 PR #3508 先例:给 `run_with_import` 方法加一行 `#[cfg(unix)]`(放在 doc 注释与方法之间,与 #3508 在 `run_in` 等处的落点形状一致)。纯测试改动,不动产品代码、不改测试语义、不碰 `src/lexer/continuation.rs` 与 `docs/api-ledger.md`。其余 helper(`new`/`base_cmd`/`finish`/`run_without_import`)仍被无 cfg 的对照测试 `issue3413_unset_import_falls_back_to_invocation_name` 引用,故不加门控。

GNU 锚点:不适用。本单是测试 harness 的 cfg 缺陷,不是 shell 语义分歧;pin 本身及其期望行为在 unix 下完全不变。

## 验证(队长复核,卷宗 ~/workspace/review-3524/CAPTAIN-VERIFY.md)

- Windows 面(单目标 x86_64-pc-windows-gnu,`-D warnings`):基底 fail-first rc=101,恰 1 错 `method 'run_with_import' is never used`(:66);修后 rc=0,0 诊断。
- Linux 腿:钉双边 6/6 = 6/6;lib 双边 1246/0/4 = 1246/0/4,名集 ∅;`-D warnings` 强制重查 1,526 次 rustc 调用,0 诊断。
- CI(run 43543416130):3 红唯一失败名均为 `issue2875`(#3292 基线);Windows tests compile check PASS,API tripwire PASS。

## 本 PR 删除了什么

什么都没删除。本 PR 只有 1 行新增(`#[cfg(unix)]`),0 行删除、0 行语义改动。
caomengxuan666 added a commit that referenced this pull request Nov 14, 2026
…3525)

## 根因

`tests/issue2272_fdvar_spawn_delivery_regressions.rs` 中 `fn rubash_in_stdin_file`(:60)无 cfg 门控,其唯一调用点(:290)落在 `#[cfg(unix)]` 测试 `issue2272_fdvar_dup_input_from_ambient_stdin` 内。Windows 下该测试被编译掉,函数变死代码,`RUSTFLAGS="-D warnings" cargo check --tests` 报 1 项 dead-code(PR #3508 复核轮在 master `5219be90` 上核实)。

另:`use std::process::{Command, Stdio};` 中的 `Stdio` 只在该函数内使用(:70 `.stdin(Stdio::from(file))`);只门控函数会让 `Stdio` 变成未用导入,在 `-D warnings` 下仍报错。故同机制连 `Stdio` 导入一并门控(#3508/#3512 先例:use 行随被门控项一并门控)。`Command` 仍被未门控的 `rubash_in` 使用,不动。

## 修法

仅 `tests/issue2272_fdvar_spawn_delivery_regressions.rs` 一文件,4 行新增、1 行删除(净 +3 行):`#[cfg(unix)]` × 2。纯测试改动,不动产品代码、不改测试语义、不碰 `src/lexer/continuation.rs` 与 `docs/api-ledger.md`。unix 下编译内容与 base 同义。

GNU 锚点:不适用。本单是测试 harness 的 cfg 缺陷,不是 shell 语义分歧;pin 本身及其期望行为在 unix 下完全不变(pin 的语义锚点见文件头注释:redir.c:237 do_redirections、redir.c:1010/:1113 redir_varassign)。

## 验证(base = master 2acdfc4)

Windows 腿(X299-2607,cargo/rustc 1.99.1,cl 19.44.35230):
- fail-first(base,未修):`RUSTFLAGS="-D warnings" cargo test --locked -j 4 --test issue2272_fdvar_spawn_delivery_regressions --no-run`:**rc=101,40s,恰好 1 项 dead-code**(`error: function 'rubash_in_stdin_file' is never used`),与 issue 计数一致。注:首轮直连 github.com clone 两次被 reset(curl 56 / early EOF),改走 gh-proxy 镜像后 clone 成功,checkout 钉死 `2acdfc41` 核验通过。
- 修后 stem 全量:`RUSTFLAGS="-D warnings" cargo test --locked -j 4 --test issue2272_fdvar_spawn_delivery_regressions`:**rc=0,40s,ERROR_LINES=0,WARNING_LINES=0**;`running 21 tests`,`test result: ok. 21 passed; 0 failed`(3 个 unix 测试在 Windows 下正确编译掉)。
- `RUSTFLAGS="-D warnings" cargo check --locked --lib --bins -j 4`:**rc=0,20s,0 error / 0 warning**。
- `rustfmt --edition 2021 --check` 该文件:**rc=0**。

Linux 腿(欠腿,见下):Simular box 盘 100% 满(仅 90M 可用,MemAvailable 仅 220M),按规则不走 box;老服务器 `~/oldsrv` 60s 超时无回显(banner 失联,与 #3512 同日形态)。修法在 unix 下是 no-op(`#[cfg(unix)]` 为真,编译内容与 base 同义,测试体未动),跑测风险低,但按纪律如实记录:Linux 24 测待队长在空闲机器上补跑。

## CI(run 43545588218)

3 腿红均为同一单测 `api::consumer_tests::issue2875_input_procsub_child_runs_as_rubash_shell`(Rust tests、Rust tests (macOS)、GNU regression goldens and canaries;其余腿全绿,含 Windows tests compile check、Cross-target check、API ledger tripwire)。与本单无关:本单只动 issue2272 测试文件,失败日志中无 issue2272 字样;该 #2875 红为已知的 lib-only-run NOBIN 陷阱(VOID 证据,#2875 另有在飞车道)。

## 本 PR 删除了什么

什么都没删除。本 PR 只有 2 行 `#[cfg(unix)]` 新增 + 1 行 use 拆行(净 +3 行),0 行语义改动。

UNVERIFIED-BY-CAPTAIN
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