Skip to content

test(infra): #767 single helper implementation + #746 fixed-issue catalogue wave + #812 space-free THIS_SH pin - #820

Merged
caomengxuan666 merged 3 commits into
masterfrom
fix/testinfra
Oct 18, 2026
Merged

caomengxuan666 merged 3 commits into
masterfrom
fix/testinfra

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Three test-infrastructure tickets, three commits, no product (src/) changes.

#767 - true-baseline: one helper implementation, parity-gated (a5980de)

scripts/true-baseline.sh staged two different helper implementations into $BASE (gcc ELF from support/{recho,zecho}.c for the oracle, an independently-rendering Rust pair for the arm) and rebuilt neither after the first seed, so helper-pair differences were counted against the engine (9 of the 21-22 differing suites depend on these helpers).

  • scripts/test-helpers/{recho,zecho}.rs are now required-byte-exact ports of support/*.c. Byte-exactness rides on how rubash writes argv onto the Windows command line (probed with an encode_wide dumper): every byte < 0x100 travels as U+00nn, valid multi-byte sequences as their code points, lone DC80-DCFF as bytes - so the port decodes the wire back to the producer's bytes and renders per recho.c (^X/^?, raw 0x80-0xFF, first-NUL stop). Clean-room behavioural port; no GPL text enters the MIT tree.
  • The harness now rebuilds both carriers from source every run and refuses to start a ledger until a helper-parity preflight passes: each side's own shell builds a fixed argv matrix (ASCII, control ^X/^?, DEL, raw 0x80-0xFF isolated escapes, empty argv, multi-arg spacing/indexing) and the od dumps must be identical, else exit 9. Valid multi-byte UTF-8 escape spellings are report-only - they hit the engine's byte-reencoding family ([encoding] 字节再编码族:$'\x81' 经 declare -p 变 \302\201(GNU \201);printf format \xe9 产出 c3 a9(GNU e9,与 $'\xe9' 原始字节自相矛盾)(P2) #540 class), not the helper pair.

Rerun, bidirectional (oracle GNU bash 5.3.0 x {debug, release} arms): 83/83 suites measured in both directions through the green gate (helper-parity.log: 24 ok, 2 report-only, each run). Remaining per-suite profile deltas (builtins 0<->341, coproc 4<->6, read 0<->2) carry zero helper-rendered bytes; a whole-ledger scan finds no same-input helper-rendering divergence - every residual argv[...] diff is an engine-side input difference (PATH-rendering, glob verdicts, tokenization) the unified helpers now render faithfully.

#746 - regression catalogue: the #750-#810 fixed-issue wave (d8c8e0f)

The skeleton (PR #774) predates the wave; this lands the ratchet's PROMOTE step plus the first batch, so every fixed issue of the wave has one catalogue line (README wave table).

Run: all 34 catalogued cases match their declared expectation (arm = this branch's release build; stale gate ok).

#812 - errors slice: space-free THIS_SH pin (99b0f36)

The after exit:/after shift: status lines (errors.snap:63-80) diverged across Windows hosts both directions while CI stayed green. Two stacked causes:

  1. the builtin divergences: dirs -l shape, shift bad-operand status, 3 non-bash builtins (setopt/unsetopt), and 17 more #759 shift usage-status semantic moved the recorded values (already re-recorded on master by 5892b6f);
  2. still live: the upstream assets expand `${THIS_SH}` UNQUOTED (errors.tests:369 -> errors10.sub:10-16 re-invokes it for every status line) and the engine auto-detects current_exe's full path - so any checkout path containing a space word-splits every sub-invocation and the status block collapses. Reproduced: same tree, same binary, run from a junction named with a space -> stdout 1037 -> 31 bytes, stderr full of D:/temp-812/no: No such file or directory.

No snapshot normalizer can repair absent lines, and the asset is GPL upstream - so run_suite_snapshot pins the value instead (the same contractual move true-baseline.sh makes on the GNU side): a copy of the engine as bash.exe under a space-free directory (scratch first, SystemRoot\\Temp fallback, cleaned up), exported as THIS_SH. The engine's inherited_sh contract keeps a bash-named existing file; the pinned path never reaches snapshot bytes, so the normalizer is untouched (the #808 runner-side-determinism shape, not a new normalizer).

Three-way byte evidence (each = cargo test --test regression upstream_suite_slice_snapshots against the committed snapshots at this HEAD):

lane result
host A - space-free checkout (D:/repo/rubash-wt-testinfra) PASS (byte-identical, no re-record needed)
host B sim - same tree via junction D:\temp-812\rub spaced host pre-fix FAIL (arith-for collapses first; errors matrix 31 vs 1037 B) -> post-fix PASS, byte-identical to host A
CI - windows regression job on this branch green; regression-snapshots artifact byte-identical to the committed files (evidence posted below once the run lands)

Discipline

  • No src/ changes; no snapshot re-record required by any commit here.
  • cargo fmt applied; full --test regression target green (70/70 on the pre-rebase tree, snapshot suite re-verified on the rebased tree).
  • Rebased on origin/master (c6f4a9b) before committing.
  • GPL red line: helpers are behavioural ports with attribution headers only; upstream test assets untouched.
  • PR not merged; three commits, one per ticket.

… sides, parity-gated

scripts/true-baseline.sh staged two helper implementations into $BASE: the
gcc ELF from third_party/bash/support/{recho,zecho}.c for the oracle and an
independently-written Rust rendering (scripts/test-helpers/*.rs) for the
rubash side, and the old only-if-missing staging kept whichever PE a
previous tree had built. A helper-pair difference then lands in the ledger
as an engine diff (9 of the 21-22 differing suites depend on these helpers;
observed as U+FFFD vs raw-byte renderings of the same argv).

- recho.rs/zecho.rs are now required-byte-exact ports of support/*.c: argv
  bytes are decoded from the Windows command line the way rubash writes it
  (probed with an encode_wide dumper: every byte < 0x100 travels as U+00nn,
  valid multi-byte sequences as their code points, lone DC80-DCFF as bytes),
  rendering follows recho.c exactly (^X control mapping, DEL ^?, 0x80-0xFF
  raw, first NUL ends the argument). Clean-room behavioural port: no GPL
  source text is copied into the MIT tree.
- true-baseline.sh rebuilds BOTH carriers from source every run and runs a
  helper-parity preflight before any ledger: each side's own shell builds a
  fixed argv matrix (ASCII, control ^X/^?, DEL, raw 0x80-0xFF isolated
  escapes, empty argv, multi-arg spacing/indexing) and the od dumps must be
  identical, else exit 9. Valid multi-byte UTF-8 escape spellings are
  report-only: they hit the engine's byte-reencoding family (#540 class,
  printf '\xc3\xa9' lands on the wire as U+00E9), not the helper pair.

Rerun bidirectionally on 5.3.0 (oracle) x {debug,release} arms: 83/83
suites measured both directions through the green gate; the remaining
per-suite profile deltas (builtins/coproc/read) carry zero helper-rendered
bytes - all residual argv-line diffs are engine-side input differences the
unified helpers now render faithfully.
…sue wave, one line each

The catalogue skeleton (scripts/regression-catalog, PR #774) predates the
wave; this lands the ratchet's PROMOTE step and the first batch of
fixed-issue rows, so every fixed issue of the wave carries one catalogue
line (README wave table; pointer rows for the faces that live in
harness/Rust-test territory per the Scope rule).

Promoted to must-match after re-verification on the current arm (13 rows):
703, 733, 738, 742, 743, 744, 745, 753, 755, 758, 761, 761b, loc-l1 (#772).
issue-756's row flips too after the case was trimmed to the fixed surface -
the residual stderr wording stays with the #551 diagnostic family, where it
belongs.

New cases (7): issue-714 (read -n/-N decoded-unit limits, PR #775), 723
(pipeline while-read stall, PR #793), 726 (definition-level dup splice +
exec group-order escape, PR #783), 776 (read -N keeps embedded newline),
788 (compound operand sets the array attribute, PR #786), 797 (sourced
bash-preexec DEBUG-trap assembly keeps the shell executable), 798 (exit
inside source terminates, subshell face so the completeness marker stays
reachable). #799 is a pointer, not a case: r/R cannot coexist on NTFS and
WSL DrvFs is itself case-insensitive, so no differential case is
expressible - it stays pinned by
tests/issue799_command_name_case_regressions.rs. #780 (startup flag) and
#803 (runner CRLF copy predicate) are pointers for the same reason.

Rows kept diverges carry refreshed notes naming the live follow-ups
(#734, #754, #757, #759, #773, #772-residual, and the #794/#795/#796
post-merge triage on the 735/737 faces).

Wiring with fast-path-differential.py (#706): both docstrings now state the
contract - ids trace to issues on both sides, and a fast-path known-
divergence that starts passing is promoted OUT of CASES into a must-match
catalogue row; the lists never both carry a fixed face.

Run: all 34 catalogued cases match their declared expectation (arm =
current branch release build; gate ok).
…ite snapshots

The errors slice's 'after exit:'/'after shift:' status lines
(errors.snap:63-80) diverged across Windows hosts both directions while CI
stayed green. Two stacked causes, one of them still live on master:

1. (already handled on master by 5892b6f + the stale-build gate) the
   #759 shift usage-status semantic moved the recorded values; binaries
   straddling that change recorded different bytes.
2. (this fix) the upstream assets expand ${THIS_SH} UNQUOTED
   (errors.tests:369 -> errors10.sub:10-16 re-invokes it for every status
   line), and with no explicit value the engine auto-detects current_exe's
   FULL path (executor/init.rs:544). When the checkout lives under a path
   containing a space, every sub-invocation word-splits - verified:
   running the slice from 'D:\temp-812\rub spaced host' collapses stdout
   1037 -> 31 bytes with 'D:/temp-812/no: No such file or directory' on
   stderr, killing exactly the after-exit/after-shift block. No snapshot
   normalizer can repair that (the lines are absent, not misspelled), and
   the asset is GPL upstream - so the runner pins the value instead, the
   same contractual move true-baseline.sh makes on the GNU side
   (THIS_SH=$GNU_BASH).

run_suite_snapshot now stages a copy of this test's own engine as
bash.exe under a space-free directory (scratch first, SystemRoot\Temp
fallback, both cleaned up) and exports THIS_SH to the child; the engine's
inherited_sh contract keeps a bash-named existing file, so the pinned
value wins on every host and a bash-named wrapper is already the blessed
conventional-name configuration.

Byte evidence, both profiles built at the current HEAD:
- host A (space-free checkout): snapshot suite green - bytes unchanged,
  no re-record needed;
- host B simulation (same tree via a junction named with a space):
  pre-fix the snapshot test FAILED (arith-for collapsed first; the
  manual errors matrix: 31 vs 1037 bytes), post-fix green - byte-identical
  to host A and to the committed snapshots;
- normalizer untouched: the pinned path never reaches snapshot bytes, so
  this reuses the #808 machine-stability shape (runner-side determinism)
  instead of adding a normalizer.

CI leg (three-way): the windows regression job on this branch runs the
same bytes; the recorded-snapshots artifact is byte-identical to the
committed files (see PR description).
@caomengxuan666

Copy link
Copy Markdown
Member Author

#812 three-way byte evidence (CI leg landed)

CI run 39147238565 (windows-latest, head 99b0f36): GNU regression goldens and canaries job = success, all other jobs green.

The regression-snapshots artifact recorded by the CI runner with this branch's engine is byte-identical to the committed snapshots: 13/13 files, 0 differing (cmp per file).

errors.snap:

committed:  975bf71250d91d44d2250a3bd78e55e03234c0601f01d90ff5f390b8e1ddd71d
CI record:  975bf71250d91d44d2250a3bd78e55e03234c0601f01d90ff5f390b8e1ddd71d

Full three-way table for the record:

lane condition result vs committed snapshots
host A (space-free checkout, D:/repo/rubash-wt-testinfra) THIS_SH pin active PASS, byte-identical
host B sim (same tree via junction D:\temp-812\rub spaced host) pre-fix FAIL — snapshot collapse (${THIS_SH} word-split at the space; errors slice stdout 1037 -> 31 B in the manual matrix)
host B sim post-fix PASS, byte-identical to host A
CI windows runner post-fix PASS, artifact byte-identical (13/13)

The errors after exit:/after shift: status block no longer depends on the host's checkout-path shape; the values themselves are pinned by 5892b6f's re-record (the #759 semantic), so the only remaining way to move those bytes is a semantic change, which the re-record protocol gates.

@caomengxuan666 caomengxuan666 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent CR of fix/testinfra (99b0f36), base c6f4a9b. Verdict: APPROVE-WITH-NITS — every load-bearing claim independently reproduced; findings below are non-blocking.

Verified

#767 (a5980de)

  • Semantic port check vs third_party/bash/support/{recho,zecho}.c: strprint is behavior-identical (<0x20 → ^+64, 0x7F → ^?, first NUL ends, 0x80-0xFF raw, argv[1..n] indexing, >\n); zecho space-join + single trailing newline + per-arg C-string truncation match %s semantics.
  • Helper-parity preflight self-run under WSL GNU 5.3.0 x debug PE: gate green, 24 OK / 2 report-only. Classification is correct: only caf\xc3\xa9 diverges (code point ≤0xFF collapses to one byte — the #540 engine family); '\xe4\xb8\xad' roundtrips byte-exactly (code point >0xFF re-encodes to identical UTF-8), so its OK is real parity, not misclassification.
  • Mutation test: single-byte corruption (b + 64 → b + 65) → 3 FAILs with od dumps → FATAL exit 9. Reverted; tree verified clean. The oracle od dump doubles as wire-level byte-class evidence (5e 41 = ^A, 5e 3f = ^?, empty argv <>, tail-arg indexing).
  • GPL clean-room: zero GPL/FSF license text in the Rust files (grep), no code-structure mirroring (the wire decoder is rubash-specific; strprint is the trivial behavior-mandated mapping); the two descriptive title lines pre-exist this PR.

#746 (d8c8e0f)

  • Ran the catalogue runner against this branch's build: all 34 cases match declared expectations (22 must-match green, 12 diverges still diverging), stale gate ok.
  • Deep spot-checks: issue-743 (a$w"b" → [aa][bb] / [a][bb] — pins the wholly-quoted pre-fix defect), issue-776 (read -N keeps [a␊b] verbatim), issue-788 (array attr bit a|2|y ×3, scalar |1, assoc A|1|v). All byte-identical GNU vs arm; each would fail pre-fix.
  • #706 contract is wired in code, not just prose: fast-path-differential exits 1 on quietly-fixed known cases ("KNOWN CASES NOW MATCHING"), and a static overlap check shows no issue tracked in both lists (differential: 154/383/707/708/709 only).
  • Pointer rows resolve: issue_780/issue_753/issue_776/issue_788 mods exist in tests/regression.rs; tests/issue799_command_name_case_regressions.rs exists; #803's CRLF copy predicate is present with the autocrlf rationale. The three exemptions are sound (780 startup-flag face; 799 r/R cannot coexist on NTFS/DrvFs so no differential case is expressible; 803 harness-face).

#812 (99b0f36)

  • Spaced-host sim at engine level: engine under "D:/temp-812/rub spaced host/" with no THIS_SH → word-split collapse ("D:/temp-812/rub: No such file or directory", rc 127, 28 bytes); with THIS_SH pinned to a space-free bash.exe copy → full block, "after exit: 0". Pre-fix FAIL → post-fix PASS reproduced.
  • inherited_sh contract (src/executor/init.rs:536-543) verified live: bash.exe-named existing file kept verbatim; wrapper.exe-named and missing-file values both fall back to auto-detect — the pin borrows documented, explicitly-blessed behavior; init.rs is not touched by this PR.
  • Bytes: committed snapshots contain zero path/placeholder content; full snapshot lane green on this host with a live pid-bearing pin path — the pin never reaches bytes (and sits inside the scrubbed scratch prefix even if a future suite echoes it).
  • No spillover: .env("THIS_SH", …) exists only in run_suite_snapshot; catalogue runner/cases and the true-baseline rub side (deliberately auto-detecting, per its header contract) are untouched.

Gates

  • CI all green at 99b0f36 (stale SKIPPED as usual); MERGEABLE.
  • cargo test --test regression: 74 passed, 0 failed on this host. cargo fmt --check clean.
  • 3 commits, each scoped exactly to its claim (3 / 11 / 1 files); third_party tree unchanged (16ddcc77); no stowaways.

Findings (non-blocking)

  1. NIT tests/regression.rs space_free_this_sh (~:463-472): the SystemRoot\Temp fallback pin path lives OUTSIDE the scrubbed scratch prefix (C:\Windows\Temp\rubash-812-thissh-<pid>\bash.exe). Today unreachable in bytes (no suite prints ${THIS_SH}; verified zero path content in committed snaps), but if a future snapshot suite ever echoes ${THIS_SH}, the fallback spelling would reintroduce pid-bearing machine-dependent bytes. Cheap hardening: also scrub the resolved this_sh path in normalize_snapshot.
  2. NIT scripts/true-baseline.sh ensure_test_helpers (~:113-118): gcc/rustc builds are 2>/dev/null || true, so a failed rebuild silently keeps the previous carrier — "rebuilt EVERY run" guarantees freshness only on success. Benign while the C source is frozen (parity gate still compares behavior), but a build failure should ideally be loud or surfaced in the parity log.
  3. OBS (adjacent, pre-existing, not introduced here): the true-baseline ledger's rub side runs with auto-detected THIS_SH, so the same unquoted-${THIS_SH} collapse fixed here for snapshots would misattribute errors-suite diff lines to the engine when a checkout lives under a spaced path. Worth a follow-up issue, not a change to this PR.
  4. ULTRA-MINOR tests/regression.rs: if create_dir_all succeeds on the fallback but the exe copy fails, the created empty dir leaks (the panic path doesn't remove it).

Nothing here blocks merge. Mutation and fixtures used during review were reverted/removed; no merge performed.

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