-
Notifications
You must be signed in to change notification settings - Fork 0
test(e2e): harness answers DSR-6n cursor queries #555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
21583bd
test(e2e): harness answers DSR-6n cursor queries (dsr_reply verb)
fentas 2c24658
test(e2e): honest scope for the dsr_child_reply scenario
fentas 3386f92
fix(e2e): address review round 1 — split queries, reply shape, plumbing
fentas 735b6ba
fix(e2e): address review round 1 (copilot) — retry writes, pre-spawn …
fentas deb7874
fix(e2e): address review round 2 — stale golden, honest scope, toggle…
fentas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| //! dsr_child_reply — statusbar on so atty actively tracks the cursor with its | ||
| //! own DSR-6n queries; that is the state in which a child's cursor reply could | ||
| //! plausibly be consumed by atty's interceptor, so it is the interesting one to | ||
| //! pin the contract under. | ||
| const atty = @import("atty"); | ||
|
|
||
| pub const statusbar: atty.StatusBar = .{ .enabled = true }; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # atty e2e — recorded environment | ||
| atty_version = "0.8.0" | ||
| cols = 80 | ||
| rows = 24 | ||
|
|
||
| [argv] | ||
| 0 = "$ATTY" | ||
| 1 = "bash" | ||
| 2 = "--norc" | ||
| 3 = "--noprofile" | ||
| 4 = "-i" | ||
|
|
||
| [forced_env] | ||
| PATH = "/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin" | ||
| TERM = "xterm-256color" | ||
| LANG = "C.UTF-8" | ||
| LC_ALL = "C.UTF-8" | ||
| HOME = "/tmp" | ||
| SHELL = "/bin/sh" | ||
| USER = "test" | ||
| PS1 = "$ " | ||
|
|
||
| [extra_env] | ||
| ATTY_BIN = ".zig-cache/e2e/dsr_child_reply/bin/atty" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| # A foreground child that queries the cursor must receive the terminal's DSR-6n | ||
| # reply. atty issues its own `ESC[6n` queries to track the prompt and strips the | ||
| # `ESC[r;cR` answers off stdin so the shell never sees them as keystrokes — so | ||
| # there is a real risk of it consuming a reply that belongs to a child (atuin's | ||
| # Ctrl+R search is the motivating case). | ||
| # | ||
| # `dsr_reply on` makes the harness answer cursor queries like a real terminal. | ||
| # Without it no replies exist at all and none of this is observable: the harness | ||
| # is otherwise a pure screen scraper. | ||
| # | ||
| # WHAT THIS GUARDS: "a foreground child's cursor reply is never consumed by | ||
| # atty's CPR filter." It passes on today's atty — it is a characterisation test | ||
| # pinning that contract against future changes to the DSR interception path, NOT | ||
| # a regression test for the atuin hang (still unreproduced, see #553). | ||
| # | ||
| # The child validates the SHAPE of what it received (`ESC[<row>;<col>`), not just | ||
| # that some R-terminated blob arrived — so stray non-CPR bytes can't be mistaken | ||
| # for a reply. Note the limit: a CPR that atty leaked is itself CPR-shaped, so | ||
| # this separates "a cursor report" from "anything else", not "the child's own | ||
| # reply" from "atty's". | ||
| # | ||
| # The child is a separate `bash -c` (its own process group, so it owns the | ||
| # terminal foreground) rather than a builtin, matching how atuin runs. The | ||
| # marker is assembled at runtime (`"CURSOR""-$M"`) so the result strings never | ||
| # appear in the echoed command line — otherwise the assertions would match the | ||
| # echo instead of the child's output. | ||
|
|
||
| cols 80 | ||
| rows 24 | ||
| timeout_ms 10000 | ||
| dsr_reply on | ||
|
|
||
| spawn $ATTY bash --norc --noprofile -i | ||
| wait_for "$" | ||
| sleep 300 | ||
|
|
||
| type "bash -c 'printf \"\\033[6n\"; re=\"\\[[0-9]+;[0-9]+$\"; IFS= read -s -r -d R -t 3 _r && { [[ $_r =~ $re ]] && M=OK || M=BAD; } || M=LOST; echo \"CURSOR\"\"-$M\"'\r" | ||
| wait_for "CURSOR-" | ||
| sleep 200 | ||
| expect_substr "CURSOR-OK" | ||
| expect_no_substr "CURSOR-LOST" | ||
| expect_no_substr "CURSOR-BAD" | ||
|
|
||
| type "exit\r" | ||
| exit_code 0 |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.