Skip to content

Commit fefea2b

Browse files
wan9chiclaude
andauthored
test(cache): emit the stalled milestone only when a test waits for it (#844)
## Motivation `remote_cache::ctrl_c_during_upload` passed on #841 but timed out on main in [`Test (windows-ignored)`](https://github.com/voidzero-dev/vite-task/actions/runs/38217517719/job/114706317248), waiting for the `uploads-pending` milestone. On Windows a milestone is the console title, and ConPTY sends only the latest title when it next renders. `vtt stalled-remote-cache` emits a `stalled` milestone when the upload arrives, which can be just after `vt run` emits `uploads-pending`. `stalled` then replaces it, and the harness waits until the test times out. `fast_fail_during_upload` has the same race, and it's why `pending_uploads` and `hide_pending_uploads` timed out on Windows in #841's first CI run. Only `ctrl_c_during_fetch` waits for `stalled`. ## Changes - `vtt stalled-remote-cache` emits the `stalled` milestone only with the new `--milestone` flag, which `ctrl_c_during_fetch` passes. - `pending_uploads` and `hide_pending_uploads` run on Windows again. #841 skipped `hide_pending_uploads` because nothing is printed after `uploads-pending`, but ConPTY sends a title change without other output, as `milestone_raw_mode_keystrokes` and `vtt exit-on-ctrlc` show. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 4a0f130 commit fefea2b

3 files changed

Lines changed: 30 additions & 20 deletions

File tree

‎crates/vt_bin/src/vtt/stalled_remote_cache.rs‎

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,42 @@ use std::{
44
sync::Arc,
55
};
66

7-
/// stalled-remote-cache \[`--stall` `<route>`\]... `<command>` \[`<args>`...\]
7+
/// stalled-remote-cache \[`--stall` `<route>`\]... \[`--milestone`\] `<command>` \[`<args>`...\]
88
///
99
/// Runs `<command>` with `VP_REMOTE_CACHE_URL` set to a loopback proxy for the
1010
/// endpoint in `VP_REMOTE_CACHE_URL`, which must be
1111
/// `http://<host>:<port>/<path>`, then exits with the command's exit code.
1212
/// Requests to a stalled route below the endpoint, such as `/store`, are never
13-
/// forwarded or answered: each emits a "stalled" milestone when it arrives,
14-
/// and its connection is held until the client closes it. Other requests are
15-
/// forwarded, each on its own connection. Ctrl-C is left to the command.
13+
/// forwarded or answered: their connections are held until the client closes
14+
/// them. Other requests are forwarded, each on its own connection. Ctrl-C is
15+
/// left to the command.
1616
///
17-
/// On Windows a milestone is the console title, which `ConPTY` sends when it
17+
/// With `--milestone`, each stalled request emits a "stalled" milestone when it
18+
/// arrives. Leave it out when the test waits for a milestone from the command:
19+
/// on Windows a milestone is the console title, which `ConPTY` sends when it
1820
/// next renders, so if the command sets one at about the same time, the
1921
/// earlier title can be lost.
2022
pub fn run(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
2123
let mut args = args;
2224
let mut stalled_routes = Vec::new();
23-
while let [flag, route, rest @ ..] = args
24-
&& flag == "--stall"
25-
{
26-
stalled_routes.push(route.clone());
27-
args = rest;
25+
let mut milestone = false;
26+
loop {
27+
match args {
28+
[flag, route, rest @ ..] if flag == "--stall" => {
29+
stalled_routes.push(route.clone());
30+
args = rest;
31+
}
32+
[flag, rest @ ..] if flag == "--milestone" => {
33+
milestone = true;
34+
args = rest;
35+
}
36+
_ => break,
37+
}
2838
}
2939
let [program, args @ ..] = args else {
3040
return Err(
31-
"Usage: vtt stalled-remote-cache [--stall <route>]... <command> [args...]".into()
41+
"Usage: vtt stalled-remote-cache [--stall <route>]... [--milestone] <command> [args...]"
42+
.into(),
3243
);
3344
};
3445
let upstream = std::env::var("VP_REMOTE_CACHE_URL")
@@ -41,6 +52,7 @@ pub fn run(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
4152
upstream: authority.to_owned(),
4253
base_path: std::format!("/{}", path.trim_end_matches('/')),
4354
stalled_routes,
55+
milestone,
4456
});
4557
ctrlc::set_handler(|| {})?;
4658

@@ -67,6 +79,8 @@ struct Proxy {
6779
base_path: String,
6880
/// Routes below `base_path` whose requests stall.
6981
stalled_routes: Vec<String>,
82+
/// Whether a stalled request emits a "stalled" milestone.
83+
milestone: bool,
7084
}
7185

7286
impl Proxy {
@@ -83,7 +97,9 @@ impl Proxy {
8397
.strip_prefix(self.base_path.as_str())
8498
.is_some_and(|route| self.stalled_routes.iter().any(|stalled| stalled == route))
8599
{
86-
vt_pty_terminal_test_client::mark_milestone("stalled");
100+
if self.milestone {
101+
vt_pty_terminal_test_client::mark_milestone("stalled");
102+
}
87103
let mut buf = [0; 4096];
88104
while client.read(&mut buf).is_ok_and(|n| n > 0) {}
89105
return;

‎crates/vt_bin/tests/e2e_snapshots/fixtures/remote_cache/snapshots.toml‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -341,10 +341,6 @@ steps = [
341341

342342
[[e2e]]
343343
name = "pending_uploads"
344-
# Skipped on Windows, where a milestone is the console title and ConPTY sends
345-
# only the latest one when it next renders: the proxy's `stalled` milestone for
346-
# check's upload can replace `uploads-pending`.
347-
cfg = "not(windows)"
348344
ignore = true
349345
steps = [
350346
{ argv = [
@@ -522,6 +518,7 @@ steps = [
522518
"stalled-remote-cache",
523519
"--stall",
524520
"/fetch",
521+
"--milestone",
525522
"vt",
526523
"run",
527524
"build",
@@ -615,9 +612,6 @@ steps = [
615612

616613
[[e2e]]
617614
name = "hide_pending_uploads"
618-
# Skipped on Windows, where a milestone is the console title and ConPTY sends
619-
# it only when it next renders: nothing is printed after `uploads-pending`.
620-
cfg = "not(windows)"
621615
ignore = true
622616
steps = [
623617
{ argv = [

‎crates/vt_bin/tests/e2e_snapshots/fixtures/remote_cache/snapshots/ctrl_c_during_fetch.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ctrl_c_during_fetch
22

3-
## `VP_REMOTE_CACHE_URL=http://127.0.0.1:0/projects/test vtt stalled-remote-cache --stall /fetch vt run build`
3+
## `VP_REMOTE_CACHE_URL=http://127.0.0.1:0/projects/test vtt stalled-remote-cache --stall /fetch --milestone vt run build`
44

55
The proxy never answers the fetch, so nothing needs to listen behind it. Ctrl-C stops the fetch, and the task doesn't start.
66

0 commit comments

Comments
 (0)