Skip to content

fix(ci): run cargo test in CI (Refs #1604) - #1605

Merged
caomengxuan666 merged 1 commit into
mainfrom
fix/1602-ci-cargo-test
Nov 13, 2026
Merged

caomengxuan666 merged 1 commit into
mainfrom
fix/1602-ci-cargo-test

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

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 caomengxuan666 changed the title fix(ci): run cargo test in CI (Refs #1602) fix(ci): run cargo test in CI (Refs #1604) Nov 13, 2026
@caomengxuan666

Copy link
Copy Markdown
Member Author

复核结论:PASS(合入后立 5 个跟进单;rust-tests 红是信号,不是合入 blocker)

本 PR 正是 #1604 要的东西:Rust 单测第一次在 CI 里跑起来,并报出真实状态(572/5)。diff 干净(单文件 +51/−0 纯插入)、YAML 合法、job 已执行;5 个失败全是树上既有属性(钉子侧 3 个、产品侧 2 个,无一由本 PR 引起);x64-default 红是基线簇、oracle 红是外部 savannah 故障;run-gate 不接 CI 的理由成立;release 不挂 rust-tests。

改动(已逐字节核)

  • 只改 .github/workflows/build-winuxcmd.yml,新增 rust-tests job(windows-2025):checkout → cache pinned toolchain → rustup 1.99.1 → cache cargo registry → cargo test --locked --no-fail-fast -p winux-cmds(rust2/)。与车道 new-job.yml 逐字节同;release 的 needs: 未动;只跑 -p winux-cmds;无产品代码;无 fix(cmds): reject bare -h for csplit/pathchk/ptx (WinuxCmd#1591) #1597 单测加回;无 run-gate 接线。

rust-tests:572 passed / 5 failed(run 43363770325,job 47s,首次执行)

5 个失败逐个定性(源码已在 head fd0b4ecf 上读过;X299 第二路径复核 4/5 复现、1 个解释):

  • F1 canon(钉子):canon.rs:310 的 !r.contains("dang") 断言自败——路径里的 "dang" 是 scratch 目录名 winux-cmds-test-canon-dang-… 本身,产品返回的绝对路径形与 GNU 一致。跟进:改 scratch 名或按 path component 断言。
  • F2 chown(钉子,H2 已确认):from_filter 在 runner 与 X299 上都因文件属主就是 Administrators 组而匹配并印 retained 行——产品行为与 GNU 同;测试把 "Administrators 永不匹配" 写死为环境无关假设,在提权 token 的机器上自相矛盾。X299 实测:文件 OWNER=BUILTIN\Administrators,chown -v --from Administrators 1234 <file> 原样输出 retained 行。跟进:钉子加固(选必非属主账号,或属主为 Administrators 时条件断言)。
  • F3 ln(产品):ln -s tgt sl 后 read_link 得绝对路径,GNU 存操作数原文。机制:fs_win::create_symlink 经 api_path 把 TARGET 也绝对化了(LINK 路径绝对化是对的,TARGET 不应)。跟进:TARGET 存原文;-r 路径一并核查。
  • F4 nice(环境 + 钉子假设):runner 上测试进程跑在 Below Normal,产品如实印出映射值 10;X299 上进程为 Normal,该格通过。映射本身的单测在 CI 里是绿的。跟进:钉子自洽断言(当前进程的映射类)或在已知优先级子进程里测。
  • F5 stat(产品):symlink 的 %s 为 0,GNU 为目标名长度(本例 3)。crate 自有文档即写 "target-name length as its size"。跟进:symlink 的 size 取 read_link 目标名长度。
  • 以上 5 个在 master 上同样失败(diff 纯 workflow,同一树、同一工具链、同一命令;fix(cmds): reject bare -h for csplit/pathchk/ptx #1593 复核时 X299 已有同族 4 个既有失败佐证)——不是本 PR 的回归。

其余 CI 腿

  • x64-default ctest:22/3840 首跑、串行重试 21/22 仍红(head-fifo issue1442 超时 ×5、ln issue1367 ×2、mkfifo ×10、seq 精度 ×1、tac issue1368 ×1、winuxcmd stat ×2;唯一重试转绿的是 fix(cmds): reject bare -h for csplit/pathchk/ptx (WinuxCmd#1591) #1597 已裁的非回归项)——与 fix(cmds): reject bare -h for csplit/pathchk/ptx #1593 的 23/3840 基线簇同形、无新名;本 PR 纯 workflow 改动,不可能引起 C++ 失败。
  • oracle job(另一 workflow):savannah gnulib clone 报 HTTP 500 ×2,外部故障;同一 workflow 在主干数分钟前是绿的。
  • arm64 default/full、x64 full、i18n-drift 均绿。

run-gate.sh 不接 CI:成立

GNU 面要 WSL(托管 runner 无),CPP 面要 Debug 版 build-vs/ 树(workflow 只产 Release)。要全量 gate 需 WSL 可用 runner 或纯 Rust gate 模式——另议,不在本 PR。既有 bash -n 语法检查保留。

合入后(队长执行)

  1. 立 5 个跟进单:F1/F2/F4 钉子侧、F3/F5 产品侧(见上)。
  2. 从 664887c2 加回 fix(cmds): reject bare -h for csplit/pathchk/ptx (WinuxCmd#1591) #1597 的 3 枚单测 + 3 枚 doc bullet(另起 PR)。
  3. release 暂不挂 rust-tests;待该 job 在 master 变绿后再另起 PR 考虑门控。

完整卷宗:~/workspace/review-winx-1605/CAPTAIN-VERIFY.md

@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 13, 2026 06:03
@caomengxuan666
caomengxuan666 merged commit d2ee03f into main Nov 13, 2026
12 of 15 checks passed
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