Skip to content

Commit dab5d8c

Browse files
branchseerclaude
andcommitted
Simplify ctrl-c e2e test to single task
- Revert pending_osc buffering in pty_terminal_test (unnecessary) - Remove "ctrl-c receivedctrl-c received" redaction (no longer needed) - Use single-package fixture with vite-task.json command instead of multi-package workspace with two concurrent tasks Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent af02671 commit dab5d8c

File tree

9 files changed

+22
-74
lines changed

9 files changed

+22
-74
lines changed

crates/pty_terminal_test/src/lib.rs

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
use std::{
2-
collections::VecDeque,
3-
io::{BufReader, Read},
4-
};
1+
use std::io::{BufReader, Read};
52

63
pub use portable_pty::CommandBuilder;
74
use pty_terminal::terminal::{PtyReader, Terminal};
@@ -28,8 +25,6 @@ pub struct TestTerminal {
2825
pub struct Reader {
2926
pty: BufReader<PtyReader>,
3027
child_handle: ChildHandle,
31-
/// OSC sequences taken from the PTY but not yet consumed by `expect_milestone`.
32-
pending_osc: VecDeque<Vec<Vec<u8>>>,
3328
}
3429

3530
impl TestTerminal {
@@ -42,11 +37,7 @@ impl TestTerminal {
4237
let Terminal { pty_reader, pty_writer, child_handle, .. } = Terminal::spawn(size, cmd)?;
4338
Ok(Self {
4439
writer: pty_writer,
45-
reader: Reader {
46-
pty: BufReader::new(pty_reader),
47-
child_handle: child_handle.clone(),
48-
pending_osc: VecDeque::new(),
49-
},
40+
reader: Reader { pty: BufReader::new(pty_reader), child_handle: child_handle.clone() },
5041
child_handle,
5142
})
5243
}
@@ -80,24 +71,15 @@ impl Reader {
8071
let mut buf = [0u8; 4096];
8172

8273
loop {
83-
// Drain new sequences from the PTY into our local buffer.
84-
self.pending_osc.append(&mut self.pty.get_ref().take_unhandled_osc_sequences());
85-
86-
// Scan for the first matching milestone, keeping the rest.
87-
let mut found = false;
88-
let mut remaining = VecDeque::with_capacity(self.pending_osc.len());
89-
for params in self.pending_osc.drain(..) {
90-
if !found
91-
&& pty_terminal_test_client::decode_milestone_from_osc8_params(&params)
92-
.is_some_and(|decoded| decoded == name)
93-
{
94-
found = true;
95-
continue;
96-
}
97-
remaining.push_back(params);
98-
}
99-
self.pending_osc = remaining;
100-
74+
let found = self
75+
.pty
76+
.get_ref()
77+
.take_unhandled_osc_sequences()
78+
.into_iter()
79+
.filter_map(|params| {
80+
pty_terminal_test_client::decode_milestone_from_osc8_params(&params)
81+
})
82+
.any(|decoded| decoded == name);
10183
if found {
10284
return self.screen_contents();
10385
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"name": "ctrl-c-test",
3-
"private": true
2+
"name": "ctrl-c-test"
43
}

crates/vite_task_bin/tests/e2e_snapshots/fixtures/ctrl-c/packages/a/package.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

crates/vite_task_bin/tests/e2e_snapshots/fixtures/ctrl-c/packages/b/package.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

crates/vite_task_bin/tests/e2e_snapshots/fixtures/ctrl-c/pnpm-workspace.yaml

Lines changed: 0 additions & 2 deletions
This file was deleted.

crates/vite_task_bin/tests/e2e_snapshots/fixtures/ctrl-c/snapshots.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
# Tests that Ctrl+C (SIGINT) propagates to and terminates running tasks.
2-
# Two packages run concurrently; both set up ctrl-c handlers and emit
3-
# a "ready" milestone. After both are ready, ctrl-c is sent.
1+
# Tests that Ctrl+C (SIGINT) propagates to and terminates a running task.
42

53
[[e2e]]
64
name = "ctrl-c terminates running tasks"
75
steps = [
86
{ argv = [
97
"vt",
108
"run",
11-
"-r",
129
"dev",
1310
], interactions = [
14-
{ "expect-milestone" = "ready" },
1511
{ "expect-milestone" = "ready" },
1612
{ "write-key" = "ctrl-c" },
1713
] },

crates/vite_task_bin/tests/e2e_snapshots/fixtures/ctrl-c/snapshots/ctrl-c terminates running tasks.snap

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,9 @@
22
source: crates/vite_task_bin/tests/e2e_snapshots/main.rs
33
expression: e2e_outputs
44
---
5-
> vt run -r dev
5+
> vt run dev
66
@ expect-milestone: ready
7-
~/packages/a$ vtt exit-on-ctrlccache disabled
8-
~/packages/b$ vtt exit-on-ctrlccache disabled
9-
@ expect-milestone: ready
10-
~/packages/a$ vtt exit-on-ctrlccache disabled
11-
~/packages/b$ vtt exit-on-ctrlccache disabled
7+
$ vtt exit-on-ctrlccache disabled
128
@ write-key: ctrl-c
13-
~/packages/a$ vtt exit-on-ctrlccache disabled
14-
~/packages/b$ vtt exit-on-ctrlccache disabled
9+
$ vtt exit-on-ctrlccache disabled
1510
ctrl-c received
16-
17-
---
18-
vt run: 0/2 cache hit (0%). (Run `vt run --last-details` for full details)
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
{
2-
"cache": false
2+
"cache": false,
3+
"tasks": {
4+
"dev": {
5+
"command": "vtt exit-on-ctrlc"
6+
}
7+
}
38
}

crates/vite_task_bin/tests/e2e_snapshots/redact.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,6 @@ pub fn redact_e2e_output(mut output: String, workspace_root: &str) -> String {
110110
}
111111
}
112112

113-
// Normalize "ctrl-c received" output: when vt and tasks all receive SIGINT,
114-
// it's a race whether one or both tasks print before the process exits.
115-
// Normalize to a single occurrence for stable snapshots.
116-
{
117-
use cow_utils::CowUtils as _;
118-
if let Cow::Owned(replaced) =
119-
output.as_str().cow_replace("ctrl-c receivedctrl-c received", "ctrl-c received")
120-
{
121-
output = replaced;
122-
}
123-
}
124-
125113
// Sort consecutive diagnostic blocks to handle non-deterministic tool output
126114
// (e.g., oxlint reports warnings in arbitrary order due to multi-threading).
127115
// Each block starts with " ! " and ends at the next empty line.

0 commit comments

Comments
 (0)