Skip to content

fix(cmds): reject bare -h for csplit/pathchk/ptx (WinuxCmd#1591) - #1597

Closed
caomengxuan666 wants to merge 2 commits into
mainfrom
fix/1591-bare-h-reject
Closed

caomengxuan666 wants to merge 2 commits into
mainfrom
fix/1591-bare-h-reject

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Refs #1591 (no Fixes — captain reviews first).

csplit, pathchk and ptx printed help with rc 0 for a bare -h; GNU coreutils
9.4 reports invalid option -- 'h' with rc 1 for all three. None of the
three option tables defined short h, so bare -h fell through argopt's
default -h → --help mapping. This wires argopt::H_REJECT_SPEC for the
three commands (same idiom as shuf/nohup/groups/who), adds one unit test per
command asserting the GNU bytes, and adds one strict TSV row per command
(cs33/pk31/px29; both copies of each row list in gen-cases.py).

Verification run by the captain-side executor after the wall reopened
(probe battery round 6 ALL PASS, 18:32 UTC): real gen-cases.py emit is a
no-op diff, --dup-check findings 4 / exit 1 identical to the HEAD
baseline, rustfmt --check clean on the three files, cargo check -p winux-cmds --tests --target x86_64-pc-windows-msvc rc=0 (the three new
unit tests + wiring compile for Windows). Linux-host cargo test /
cargo check cannot execute on this tree: the lib test target fails to
compile on Linux identically on head and base (Windows-only test code in
stat/nice/nohup/test_cmd/timeout/who/winsys — pre-existing, verified by
stash comparison). Test execution (head pass + base fail-first) is for
the review round (CI/X299).

本 PR 删除了什么:无。本 PR 只增加代码与测试用例,未删除任何文件、命令、选项或公开接口。

UNVERIFIED-BY-CAPTAIN

@caomengxuan666

Copy link
Copy Markdown
Member Author

复核结论:PASS(附 Owed-1 执行债,合入轮在 X299 上兑付)

PR #1597(Refs #1591,头 67b53aca)复核通过。csplit/pathchk/ptx 裸 -h 错当 --help 的修法成立;factor 不动。

逐腿结果(复核员独立重跑,非车道自述)

  • diff 全读(7 文件 +66/−0):三命令各 +19,与 shuf 已有形逐字同构(OPTS += H_REJECT_SPEC;parse 后、--help 检查前 rejected_short_h;doc bullet;单测 short_h_is_rejected_like_gnu)。gen-cases.py 两份定义皆补,三 TSV 各 +1 strict 行(cs33/pk31/px29)。未碰 factor、run-gate.sh、argopt.rs、winux-core。
  • 机制闭合:argopt.rs 基底亲读——短簇臂仅当 OPTS 未定义 short h 时才把独个 -h 映射到 --help;rejected_short_h 命中 marker 即调 usage_error 返回 Some(1);winux-core usage_error 输出确为 <prog>: invalid option -- 'h' + Try '<prog> --help' for more information.。
  • GNU oracle(本地 coreutils 9.4 自跑):csplit/pathchk/ptx/shuf 的 -h 均为 rc 1 + 两行诊断、stdout 空,与单测断言逐字节同;factor -h rc 0(12: 2^2 3),不动。
  • 构建与检查(复核员在新鲜 clone 上独立重跑):
    • cargo check -p winux-cmds --tests --target x86_64-pc-windows-msvc:rc=0(31.84s)。
    • Linux cargo test … --no-run:rc=101,20 errors,与车道 stash 对照逐字同;错误逐一归属 nice 6 / test_cmd 4 / nohup 3 / timeout 3 / stat 2 / who 1 / winsys 1——七个文件全是本 PR 未碰的 Windows-only 文件,三命令零 error。
    • 真实 gen-cases.py emit:零 diff,true.tsv 793 字节、hash 46f26b99… 未变;--dup-check findings 4 / exit 1,与基线同;rustfmt --check 三文件 clean。
  • 正文:Refs #1591 一处;closing 词邻接 issue 号 = 0;「本 PR 删除了什么」节在;UNVERIFIED-BY-CAPTAIN 在;执行缺口已如实披露,未冒充。
  • 交集:区间 6fc5ebf7..c74112c0 10 文件 ∩ 本 PR 7 文件 = 仅 gen-cases.py 一文件;基底坐标逐 hunk 核对,fix(timeout,nohup,nice): execvp-form child resolution for non-PE targets (#1587) #1588 的改动与本 PR 的 6 处新增均不重叠(最近间隔 25 行)。须 update-branch,预计 clean;若冲突,停手回报队长。

终头 CI 全读(runs 43283331302 / 43283331314)

8 pass + 5 skipping + 1 fail:compare / baseline / baseline-growth / arm64 default / arm64 full / x64 full / i18n-drift / oracle 全部 pass;5 项 skipping;唯一红腿 build-windows (x64, default)(1h1m55s),红步仅 Run Unit Tests (ctest)。

红腿定性 base-red:头腿 ctest 失败 23 名;与基底 6fc5ebf7 的 master push 跑(run 43245017935)同腿失败名集做程序化集合比较——23 = 23,逐名完全相同,零新名、零修复名(head fifo issue1442 ×6、ln issue1367 ×2、mkfifo ×11、seq ×1、tac issue1368 ×1、stat ×2)。按 #1589 卷宗 §9 放行。

Owed-1:钉执行(合入轮在 X299 上兑付,不得冒充)

三枚 Rust 单测 + 三枚 gate 行在任何地方均未执行过:全仓无 cargo test 步骤,3840 个 ctest 名全是 C++ gtest 测试(与基底跑程序化比较:head-only []、base-only []);无 CI job 调用 run-gate.sh,cs33/pk31/px29 在头腿日志全文中出现 0 次。合入轮须在 X299 上执行(单测头 3/3 + 基底 fail-first;bash gate/run-gate.sh csplit pathchk ptx),有执行证据方可合入。另有 CI 覆盖缺口(Owed-2,卷宗附录 A)建议队长合入后另立。

合入条件

@caomengxuan666

Copy link
Copy Markdown
Member Author

队长关闭:superseded by merged #1593。

同一修复面、同一机制(argopt::H_REJECT_SPEC + rejected_short_h,与 shuf 同形),外部 PR #1593 先到(2026-11-12T16:51:23Z),已合入 bb489e0e(2026-11-13T03:07:07Z),#1591 已随之关闭。本 draft 不再合入、不竞速。

#1593 的合入证据:X299 直接探针三命令 -h 皆 rc=1、stderr 与 GNU coreutils 9.4 oracle sha256 一致;新头 CI 8 pass + 5 skipping + 1 fail(x64-default 23/3840,基线簇内一员 Timeout 互换,csplit/pathchk/ptx 零失败)。

本 PR 自身的腿也已验证过(X299,2026-11-13 08:31–08:53 CST,STOP 前跑完,附录见卷宗):头单测 3/3 通过、基底 fail-first 0/3(断言点 panic);直接探针 rc=1、stderr 与 GNU 逐字节同;gate win-only 12/12,GNU-gated 0/81 皆 g_rc=MISSING(PC 无 WSL,环境原因非产品失败)。seq.seq_streams_beyond_billion_iterations_issue1376 队长已裁为 flake(同 run 重试 112.83s 即过);head…byte_mode 在新头上过,非回归。

去留:三枚 Rust 单测 + 三枚 //! doc bullet 本次不吸收——全仓无 CI 步骤运行 cargo test,吸收了也不会执行(缺口已另立 #1602)。单测与 bullet 原文保留在本分支 fix/1591-bare-h-reject(头 664887c2,X299 3/3 + fail-first 已验证);#1602 的 cargo-test 步骤落地后,从该分支重新加回。

caomengxuan666 added a commit that referenced this pull request Nov 13, 2026
fix(ci): run cargo test in CI (Refs #1604)

## 根因

全仓没有任何 workflow 步骤运行 Rust 单测。`cargo test -p winux-cmds` 在树内存在且可跑(X299 实测 529 个单测),但 CI 从不跑它:x64-default 腿的 3840 个测试名全是 C++ gtest(ctest),Rust 单测 0 次。gate 行同样从不执行。后果是已验证的单测无 CI 守护——#1597 的三枚 `short_h_is_rejected_like_gnu` 单测在 X299 上已验证(头 3/3、基底 fail-first 0/3),但合入后未被吸收;吸收了也不会在 CI 跑,形同死代码。

## 证据

- 全仓 3 个 workflow(`benchmark-speed-matrix.yml`、`build-winuxcmd.yml`、`gnu-master-differential.yml`)中无任何 `cargo test` 步骤;`build-windows` job 只在 x64 + default 腿跑 ctest。
- `build-windows` 已有 pinned Rust 工具链(`RUST2_TOOLCHAIN: "1.99.1"`)的 cache + 安装步骤,只是缺测试调用。
- `rust2/Cargo.lock` 与 workspace 同步,`--locked` 安全;suite 为 X299 已验证的 529 测。

## 本 PR 做的事

在 `build-winuxcmd.yml` 中新增 `rust-tests` job(windows-2025,与 ctest 腿并列、失败名集单独裁断):checkout → cache pinned toolchain → rustup 安装 1.99.1 → cache cargo registry → `cargo test --locked --no-fail-fast -p winux-cmds`(`rust2/` 目录)。只跑 `-p winux-cmds` 这一已验证的集合;其余 crate 的 suite 待同样验证后再扩。

`run-gate.sh` 本次不接进 CI:它的 GNU 面要 WSL、CPP 面要 Debug 版 `build-vs/` 树,两者托管 runner 上都没有(详见 REPORT §3);现有的 `bash -n` 语法检查保留。

## 本 PR 删除了什么

什么也没删除。纯新增一个 CI job;未动产品代码,未动其余 job(含 `release` 的 `needs:` 未改,是否让 release 门控 `rust-tests` 请复核时定)。#1597 的 3 枚单测 + 3 枚 doc bullet 本次不加回,待本步骤在 master 变绿后再另起 PR。

UNVERIFIED-BY-CAPTAIN
caomengxuan666 added a commit that referenced this pull request Nov 13, 2026
Re-add the 3 `short_h_is_rejected_like_gnu` unit tests (csplit/pathchk/ptx) and the 3 matching `//!` doc bullets that were held back when #1597 was closed as superseded by #1593.

What was re-added
- `rust2/crates/winux-cmds/src/csplit.rs`: 1 test + 1 doc bullet (2 `//!` lines)
- `rust2/crates/winux-cmds/src/pathchk.rs`: 1 test + 1 doc bullet
- `rust2/crates/winux-cmds/src/ptx.rs`: 1 test + 1 doc bullet
- 42 insertions, 0 deletions, 3 files. No product-code change, no workflow change.

Why now
- The product fix (argopt `H_REJECT_SPEC` + `rejected_short_h`) already landed on master via #1593 (bb489e0); only the tests + doc bullets were missing.
- PR #1605 (d2ee03f) put `cargo test -p winux-cmds` into CI (rust-tests job), so these tests will actually execute now. They were held back pending exactly that.

Evidence (X299-2607, Windows)
- Head (4bcbaf7): `cargo test -p winux-cmds short_h_is_rejected_like_gnu` -> `test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 577 filtered out`
- Base fail-first (6fc5ebf + re-add patch topped up; pre-#1593 tree without the product fix): `test result: FAILED. 0 passed; 3 failed; 0 ignored; 0 measured; 533 filtered out`
- Fresh builds proven: distinct `Compiling winux-cmds` paths per tree, distinct test-binary sha256 (head 40cbdb41…, base 62197a84…).
- `rustfmt --check` rc=0 on all three touched files (head + base).

Notes
- The gate TSV rows + gen-cases.py rows from the original #1591 commit were deliberately NOT re-added: they belong to run-gate.sh, which is not wired into CI.
- #1597 itself stays closed (superseded); this PR only re-adds its tests/bullets.

本 PR 删除了什么
- Nothing was deleted. 42 insertions, 0 deletions.

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