Files
dev/vendor/codex/exec-server/testing/wine_exec_server.rs
T
zeekay 25f1f1da4f vendor: upstream lives under vendor/, so ours is what is left
codex-rs/ is a read-only mirror of openai/codex that just-every refreshes and
we never edit. It sat at the repo root next to code-rs/, the product, and the
only thing separating them was that everyone knew. Nothing checked it.

That knowing is what makes branding endless. There are ~400 upstream-brand
literals in code-rs today and ~224 of ours, hand-placed on the same lines the
sync delta lands on, so every sync re-fights the same 17 files. You cannot fix
that while the line between "theirs" and "ours" is a convention.

vendor/codex/ makes it a boundary. Everything under vendor/ is upstream: never
branded, never edited, replaced wholesale on sync. Everything outside it is
ours and must carry our name — which is now a question a test can ask.

code-rs coupled to the mirror through exactly one line, an include_str! of
models.json, and it still does. The other 17 files are path strings.

Syncing changes by one sed: just-every's delta names codex-rs/, so rewrite the
patch paths to vendor/codex/ before applying it.
2026-08-07 21:22:34 -07:00

47 lines
1.6 KiB
Rust

//! Test support for running the Windows exec-server under Wine.
use std::future::Future;
use std::path::PathBuf;
use anyhow::Context;
use anyhow::Result;
use tokio::io::AsyncBufReadExt;
use tokio::io::BufReader;
use wine_test_support::WineTestCommand;
/// Runs the Windows exec-server under Wine for the duration of a scoped operation.
pub struct WineExecServer;
impl WineExecServer {
/// Starts the server, passes its WebSocket URL and Wine prefix to `operation`, and tears it
/// down afterward.
pub async fn scope<T, F, Fut>(self, operation: F) -> Result<T>
where
F: FnOnce(String, PathBuf) -> Fut,
Fut: Future<Output = Result<T>>,
{
let executable = codex_utils_cargo_bin::cargo_bin("wine-windows-exec-server")?;
let mut exec_server = WineTestCommand::new(executable)
.env("CODEX_HOME", r"C:\codex-home")
.spawn()?;
let wine_prefix = exec_server.prefix_path().to_path_buf();
let stdout = exec_server.take_stdout();
exec_server
.scope(async move {
let mut lines = BufReader::new(stdout).lines();
let exec_server_url = loop {
let line = lines
.next_line()
.await?
.context("Wine exec-server exited before reporting its URL")?;
if line.starts_with("ws://") {
break line;
}
};
operation(exec_server_url, wine_prefix).await
})
.await
}
}