From 8417f13100a64d610687db2572b19b852447d5dd Mon Sep 17 00:00:00 2001 From: wan9chi Date: Mon, 12 Oct 2026 17:34:02 +0800 Subject: [PATCH] test(cache): emit the stalled milestone only when a test waits for it On Windows a milestone is the console title, and ConPTY sends only the latest title when it next renders. The `stalled` milestone from `vtt stalled-remote-cache` could replace `uploads-pending`, so the cases that wait for it timed out. The proxy now emits `stalled` only with `--milestone`, which only ctrl_c_during_fetch uses, and pending_uploads and hide_pending_uploads run on Windows again. Co-Authored-By: Claude Opus 5.5 --- crates/vt_bin/src/vtt/stalled_remote_cache.rs | 40 +++++++++++++------ .../fixtures/remote_cache/snapshots.toml | 8 +--- .../snapshots/ctrl_c_during_fetch.md | 2 +- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/crates/vt_bin/src/vtt/stalled_remote_cache.rs b/crates/vt_bin/src/vtt/stalled_remote_cache.rs index 51376f6ed..13d093a5b 100644 --- a/crates/vt_bin/src/vtt/stalled_remote_cache.rs +++ b/crates/vt_bin/src/vtt/stalled_remote_cache.rs @@ -4,31 +4,42 @@ use std::{ sync::Arc, }; -/// stalled-remote-cache \[`--stall` ``\]... `` \[``...\] +/// stalled-remote-cache \[`--stall` ``\]... \[`--milestone`\] `` \[``...\] /// /// Runs `` with `VP_REMOTE_CACHE_URL` set to a loopback proxy for the /// endpoint in `VP_REMOTE_CACHE_URL`, which must be /// `http://:/`, then exits with the command's exit code. /// Requests to a stalled route below the endpoint, such as `/store`, are never -/// forwarded or answered: each emits a "stalled" milestone when it arrives, -/// and its connection is held until the client closes it. Other requests are -/// forwarded, each on its own connection. Ctrl-C is left to the command. +/// forwarded or answered: their connections are held until the client closes +/// them. Other requests are forwarded, each on its own connection. Ctrl-C is +/// left to the command. /// -/// On Windows a milestone is the console title, which `ConPTY` sends when it +/// With `--milestone`, each stalled request emits a "stalled" milestone when it +/// arrives. Leave it out when the test waits for a milestone from the command: +/// on Windows a milestone is the console title, which `ConPTY` sends when it /// next renders, so if the command sets one at about the same time, the /// earlier title can be lost. pub fn run(args: &[String]) -> Result<(), Box> { let mut args = args; let mut stalled_routes = Vec::new(); - while let [flag, route, rest @ ..] = args - && flag == "--stall" - { - stalled_routes.push(route.clone()); - args = rest; + let mut milestone = false; + loop { + match args { + [flag, route, rest @ ..] if flag == "--stall" => { + stalled_routes.push(route.clone()); + args = rest; + } + [flag, rest @ ..] if flag == "--milestone" => { + milestone = true; + args = rest; + } + _ => break, + } } let [program, args @ ..] = args else { return Err( - "Usage: vtt stalled-remote-cache [--stall ]... [args...]".into() + "Usage: vtt stalled-remote-cache [--stall ]... [--milestone] [args...]" + .into(), ); }; let upstream = std::env::var("VP_REMOTE_CACHE_URL") @@ -41,6 +52,7 @@ pub fn run(args: &[String]) -> Result<(), Box> { upstream: authority.to_owned(), base_path: std::format!("/{}", path.trim_end_matches('/')), stalled_routes, + milestone, }); ctrlc::set_handler(|| {})?; @@ -67,6 +79,8 @@ struct Proxy { base_path: String, /// Routes below `base_path` whose requests stall. stalled_routes: Vec, + /// Whether a stalled request emits a "stalled" milestone. + milestone: bool, } impl Proxy { @@ -83,7 +97,9 @@ impl Proxy { .strip_prefix(self.base_path.as_str()) .is_some_and(|route| self.stalled_routes.iter().any(|stalled| stalled == route)) { - vt_pty_terminal_test_client::mark_milestone("stalled"); + if self.milestone { + vt_pty_terminal_test_client::mark_milestone("stalled"); + } let mut buf = [0; 4096]; while client.read(&mut buf).is_ok_and(|n| n > 0) {} return; diff --git a/crates/vt_bin/tests/e2e_snapshots/fixtures/remote_cache/snapshots.toml b/crates/vt_bin/tests/e2e_snapshots/fixtures/remote_cache/snapshots.toml index 74f5130f2..a08b697f8 100644 --- a/crates/vt_bin/tests/e2e_snapshots/fixtures/remote_cache/snapshots.toml +++ b/crates/vt_bin/tests/e2e_snapshots/fixtures/remote_cache/snapshots.toml @@ -341,10 +341,6 @@ steps = [ [[e2e]] name = "pending_uploads" -# Skipped on Windows, where a milestone is the console title and ConPTY sends -# only the latest one when it next renders: the proxy's `stalled` milestone for -# check's upload can replace `uploads-pending`. -cfg = "not(windows)" ignore = true steps = [ { argv = [ @@ -522,6 +518,7 @@ steps = [ "stalled-remote-cache", "--stall", "/fetch", + "--milestone", "vt", "run", "build", @@ -615,9 +612,6 @@ steps = [ [[e2e]] name = "hide_pending_uploads" -# Skipped on Windows, where a milestone is the console title and ConPTY sends -# it only when it next renders: nothing is printed after `uploads-pending`. -cfg = "not(windows)" ignore = true steps = [ { argv = [ diff --git a/crates/vt_bin/tests/e2e_snapshots/fixtures/remote_cache/snapshots/ctrl_c_during_fetch.md b/crates/vt_bin/tests/e2e_snapshots/fixtures/remote_cache/snapshots/ctrl_c_during_fetch.md index 50cfbb807..c2eda5069 100644 --- a/crates/vt_bin/tests/e2e_snapshots/fixtures/remote_cache/snapshots/ctrl_c_during_fetch.md +++ b/crates/vt_bin/tests/e2e_snapshots/fixtures/remote_cache/snapshots/ctrl_c_during_fetch.md @@ -1,6 +1,6 @@ # ctrl_c_during_fetch -## `VP_REMOTE_CACHE_URL=http://127.0.0.1:0/projects/test vtt stalled-remote-cache --stall /fetch vt run build` +## `VP_REMOTE_CACHE_URL=http://127.0.0.1:0/projects/test vtt stalled-remote-cache --stall /fetch --milestone vt run build` The proxy never answers the fetch, so nothing needs to listen behind it. Ctrl-C stops the fetch, and the task doesn't start.