Skip to content

test(repl): execution-level paste regressions for empty-line fidelity and #309 coverage (refs #291) - #317

Merged
caomengxuan666 merged 1 commit into
masterfrom
test/paste-execution-regressions
Oct 13, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
test/paste-execution-regressions

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

背景(纠偏后重开,取代 #315)

#291 的"最小复现"被证伪:探针 zz_minimal_empty_line_paste_probe 的负断言 !screen.contains("cho two") 是子串陷阱——"cho two" 是正确渲染 "echo two" 的严格子串,健康 shell 也必失败。抓取的失败屏幕里 echo two 渲染完整、双输出正确、单次提交;另一路 ~70 次执行级验证(debug/release/已装 × 出厂/claim × 6 种写入形态)零复现。本 PR 不关 #291——它等 owner 侧一手证据(history 字节 / rc 内容 / 终端版本 / IME / 构建来源)。

本 PR 交付(全部测试,零运行时代码改动)

  1. 执行级粘贴回归(tests/interactive.rs,6 条):粘贴体内嵌 echo RES_$((40+2)) 形态,断言输出 RES_42——该串不存在于回显输入(回显是未展开的 $((40+2))),marker 出现即证明该行逐字节完整地执行了;吞掉行首则命令变 cho RES_... not-found、无 marker、必红。全套禁用 screen 子串断言。形态覆盖:owner burst + 静默后独立 Enter、连续两个空行、空行后缩进行、纯 CRLF 无空行对照、claimed/custom-PS1(issue comment 3 指出、原 30 连跑从未覆盖的变量)。
  2. fix(repl): a paste burst's trailing bare Enter submits the buffered chunk (closes #308) #309 覆盖验证(判别力已证):empty_line_paste_same_burst_enter_submits_on_first_enter —— 粘贴体(含空行)与提交 Enter 同一次写入(send(paste + "\r"),burst 窗口内),测试不再发送任何输入:首个 Enter 必须提交整块。判别力实测:pre-fix(repl): a paste burst's trailing bare Enter submits the buffered chunk (closes #308) #309(1f2180d)上红(Enter 被吞、无输出超时),master 上绿。
  3. 单元字节保真钉(repl.rs,4 条):feed_paste_burst() 把一次写入 CRLF 粘贴的精确控制台事件流(每个 CR 的排队 LF partner 按 fix(repl): a paste burst's trailing bare Enter submits the buffered chunk (closes #308) #309 后语义被探针消费)灌过 PasteChunkEditMode,从翻译后事件重组出到达 reedline 的文本,四种形态(owner burst / 连续两空行 / 缩进行 / 无空行对照)逐一断言与输入逐字节相等。

相邻语义(全部保持,全绿)

验证

  • cargo fmt --all --check 干净;RUSTFLAGS="-D warnings" cargo check --all-targets 干净。
  • RUST_TEST_THREADS=1 NIU_INTERACTIVE_TESTS=1 cargo test --test interactive × 3:每次 49 passed,唯一红为既有基线 ctrl_d_after_background_job_exits。
  • cargo test --lib -p niubash-runtime:478 passed。

#291 后续

保持 open,等 owner 在含 #309 的构建上重放原脚本;若再现,请提供:niu --version 的 rubash hash、%USERPROFILE%\.niubashrc 内容、粘贴方式(WT 右键 / Ctrl-V / conhost QuickEdit)、终端版本、是否 IME 注入。history 字节(history 输出对照原脚本)可直接定位丢失发生在输入路径还是执行路径。

… and #309 coverage (refs #291)

The niubash#291 "minimal repro" is a false positive: the scratch probe's
negative assertion !screen.contains("cho two") fails on a CORRECT run
too, because "cho two" is a strict substring of the intact rendering
"echo two". Every captured failure screen shows "echo two" complete with
both outputs correct on a single submit; ~70 execution-level runs across
builds/claim/write-shapes reproduce no byte loss. #291 therefore stays
OPEN pending owner-side evidence (history bytes / rc / terminal / IME /
build provenance) - this PR closes nothing.

What lands here, all test-only (zero runtime code changed):

- Unit (crates/niubash-runtime/src/repl.rs): feed_paste_burst() feeds the
  exact console event stream of a one-write CRLF paste through
  PasteChunkEditMode (scripted lookahead queue, post-#309 semantics:
  every pasted CR consumes its queued LF partner) and reassembles the
  text reaching reedline from the translated events. Four shapes must
  reassemble byte-for-byte: the reported empty-line burst, two
  consecutive empty lines, an indented line after an empty line, and a
  no-empty-line CRLF control.

- Interactive (tests/interactive.rs): execution-level marker technique -
  the pasted body carries `echo RES_$((40+2))`-shaped lines, so the
  output RES_42 appears nowhere in the echoed input and proves the line
  executed with every leading byte intact; a swallowed head leaves no
  marker. Substring assertions against the screen are banned in this
  suite (the probe's trap). Shapes: the owner burst with a settled
  submit, the SAME-burst submit Enter (one write - niubash#309 coverage
  on the empty-line shape: first Enter must submit, the test sends
  nothing else), two consecutive empty lines, indented line, the
  no-empty-line control, and the claimed/custom-PS1 surface from issue
  comment 3 (the one variable the original 30-run sweep never varied).

Adjacent semantics pinned green on current master: whole-CRLF-block
integrity (#288 surface), burst interior Enters stay data (#284), the
burst-settled Enter submits the whole chunk once, and #309's first-Enter
submit holds on the empty-line shapes.

Verification: cargo fmt --check clean; RUSTFLAGS="-D warnings" cargo
check --all-targets clean; RUST_TEST_THREADS=1 NIU_INTERACTIVE_TESTS=1
cargo test --test interactive: new suite green; lib suite green.
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