Files
imeai-aKode/akode-rs/rmcp-client/tests/foreign_stdio_cwd.rs
andrea.difonzo 7c1c6dfa8d Rinomina: crate akode-*, cartelle akode-rs/ e akode-cli/, binario akode, ~/.akode, AKODE_* (A)
Riapplica la fase 5 di aKode (86e7c72e) sulla base ripulita:
- crate codex-* -> akode-*, codex-rs -> akode-rs, codex-cli -> akode-cli, binario e ausiliari akode;
- ~/.codex -> ~/.akode, CODEX_HOME -> AKODE_HOME, variabili CODEX_* -> AKODE_*, .codex/ -> .akode/ di progetto;
  nessun fallback a ~/.codex o a CODEX_*;
- testi per l'utente "Codex" -> "aKode"; testi verso il modello e istruzioni di sistema invariati;
- snapshot insta rinominati (non ancora rigenerati).
I conflitti con la base ripulita sono stati risolti riapplicando la rinomina ai file senza le
funzioni di imeAI (script di mappa dei token per file).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-17 12:37:52 +01:00

68 lines
2.0 KiB
Rust

use std::ffi::OsString;
use std::sync::Arc;
use std::sync::Mutex;
use akode_exec_server::ExecBackend;
use akode_exec_server::ExecBackendFuture;
use akode_exec_server::ExecParams;
use akode_exec_server::ExecServerError;
use akode_rmcp_client::ExecutorStdioServerLauncher;
use akode_rmcp_client::RmcpClient;
use akode_utils_path_uri::PathUri;
use pretty_assertions::assert_eq;
#[derive(Default)]
struct RecordingExecBackend {
params: Mutex<Option<ExecParams>>,
}
impl ExecBackend for RecordingExecBackend {
fn start(&self, params: ExecParams) -> ExecBackendFuture<'_> {
let mut recorded_params = match self.params.lock() {
Ok(recorded_params) => recorded_params,
Err(poisoned) => poisoned.into_inner(),
};
*recorded_params = Some(params);
Box::pin(async {
Err(ExecServerError::Protocol(
"stop after recording executor request".to_string(),
))
})
}
}
#[tokio::test]
async fn executor_stdio_forwards_foreign_absolute_cwd_as_path_uri() {
#[cfg(not(windows))]
let cwd = r"C:\Users\openai\share";
#[cfg(windows)]
let cwd = "/home/openai/share";
#[cfg(not(windows))]
let expected_cwd: PathUri = "file:///C:/Users/openai/share"
.parse()
.expect("expected cwd should be a path URI");
#[cfg(windows)]
let expected_cwd: PathUri = "file:///home/openai/share"
.parse()
.expect("expected cwd should be a path URI");
let backend = Arc::new(RecordingExecBackend::default());
let launcher = Arc::new(ExecutorStdioServerLauncher::new(backend.clone()));
let _ = RmcpClient::new_stdio_client(
OsString::from("echo"),
Vec::new(),
/*env*/ None,
&[],
Some(cwd.to_string()),
launcher,
)
.await;
let params = backend
.params
.lock()
.expect("recorded params lock should not be poisoned")
.take()
.expect("executor start request should be recorded");
assert_eq!(params.cwd, expected_cwd);
}