Repository navigation
test(repl): pin empty-line paste byte fidelity; retire the #291 probe's self-failing assertion (closes #291) - #315
Closed
caomengxuan666 wants to merge 1 commit into
Closed
caomengxuan666 wants to merge 1 commit into
caomengxuan666 wants to merge 1 commit into
Conversation
…'s self-failing assertion (closes #291) The reported P1 minimal repro - one burst of 'echo one\r\n\r\necho two \r\n\n' plus a separate submit Enter, screen shows 'cho two' - does not reproduce a byte loss at 1f2180d. The probe failed 5/5 runs on ONE assertion: !screen.contains("cho two") is unfailing on a CORRECT run too, because 'cho two' is a strict substring of the intact rendering 'echo two'. The captured screen in every failure shows 'echo two' complete, both outputs correct, single submit. Byte fidelity is now pinned at two layers: - unit (crates/niubash-runtime/src/repl.rs): feed_paste_burst() feeds the exact console event stream through PasteChunkEditMode with the scripted lookahead queue and reassembles the text that reaches reedline from the translated events. Four shapes - the owner burst, two consecutive empty lines, an indented line after an empty line, and a no-empty-line CRLF control - must reassemble byte-for-byte (CRLF folded to LF). The empty-line boundary handling (translate_event's pending CRLF push at repl.rs:863-891 and enter_opens_chunk's partner consumption at repl.rs:680-731) is exact: no off-by-one exists to correct at this rev. - interactive (tests/interactive.rs): the scratch probe becomes empty_line_paste_keeps_the_next_line_intact with the sound swallow check - every 'cho two' on screen must be the tail of an intact 'echo two' (count equality); a real swallow leaves an orphan (the executed 'cho two' line and its not-found diagnostic) and breaks it. Marker-output variants ($M1/$M2) prove both lines EXECUTE, including the line after the empty line, plus: two consecutive empty lines, an indented line after an empty line, a no-empty-line CRLF control, and the claimed/custom-PS1 surface from issue comment 3 (the one variable the original 30-run sweep never varied - passes too). Adjacent semantics pinned by the same suite (all green, unchanged code): whole-CRLF-block integrity (#288 surface, control test), burst interior Enters stay data (#284: no mid-burst execution, asserted by the marker variants' single submit), the burst-settled Enter submits the whole chunk once (every variant), and #308 is NOT touched here - it is a distinct defect in the same function with its own fix pending on fix/308-burst-enter-submit. 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 x3 = 48 passed + the pre-existing baseline ctrl_d_after_background_job_exits red each run; lib suite 470 passed.
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #291.
结论(TL;DR)
#291 的“最小复现”不成立:1f2180d 的粘贴管线在空行边界没有任何字节丢失。 报告中的探针
zz_minimal_empty_line_paste_probe连续 5/5 红在同一断言上,而断言本身自相矛盾:"cho two"是正确渲染"echo two"的严格子串——任何一次完全正确的执行都必然包含"cho two",该断言在任何正确运行上都不可能通过。5 次失败的全部屏幕快照里echo two渲染完整、one/two输出正确、单次 Enter 提交整块。根因(file:line)
crates/niubash-runtime/src/repl.rs:863-891(translate_event的 pending 分支:CR 进数据、LF 按last_bare_cr配对折叠)repl.rs:680-731(enter_opens_chunk:首 CR 的 lookahead 消费排队的 LF,CRLF = 一个\n)\r\n\r\n→\n\n)\n、其 LF 被配对折叠tests/interactive.rs:1708(子串负断言)证明方式:新增
feed_paste_burst()(repl.rs 单元测试)把 owner burst 的精确控制台事件流(含每个 CR 的排队 LF partner、尾随孤立 LF)灌过PasteChunkEditMode,从翻译后的事件重组出到达 reedline 的文本,断言与输入逐字节相等(CRLF 折叠为 LF)。四种形态全绿。Owner 症状对照表
if is_even 10; then→_even 10; then(丢if is,空行后)echo one\r\n\r\necho two\r\n\n,事件级重组 + 屏幕渲染 + 执行输出三层断言echo "===== Bash 非交互测试脚本 ====="→ 丢echo(空行后)user@host ~ %,comment 3,原 30 连跑未覆盖的变量)四个相邻语义的回归证明(全部共用该代码,全部保持,零代码改动)
crlf_paste_without_empty_lines_control_keeps_every_line_intact+ 单元paste_chunk_reassembles_crlf_block_without_empty_lines_byte_exact。paste_chunk_detector_*单元组保持全绿。\r,一次提交全部执行。translate_event但是独立缺陷,本 PR 未触碰——其修复已在fix/308-burst-enter-submit(022871c)完成,建议先合该 PR、本 PR 若有文案冲突以它为准 rebase。测试
paste_chunk_reassembles_empty_line_paste_byte_exact、..._two_consecutive_empty_lines_...、..._indented_line_after_empty_line_...、..._crlf_block_without_empty_lines_...。empty_line_paste_keeps_the_next_line_intact(正确表述的吞字检查:matches("cho two") == matches("echo two")计数相等,孤儿出现即红)、marker 执行证明、连续两空行、缩进行、无空行对照、claimed-PS1 变体。验证
cargo fmt --all --check干净;RUSTFLAGS="-D warnings" cargo check --all-targets干净。RUST_TEST_THREADS=1 NIU_INTERACTIVE_TESTS=1 cargo test --test interactive× 3:每次 48 passed,唯一红为既有基线ctrl_d_after_background_job_exits。cargo test --lib -p niubash-runtime:470 passed。