Files
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

78 lines
2.3 KiB
Rust

use std::path::Path;
use akode_arg0::Arg0DispatchPaths;
use akode_arg0::Arg0PathEntryGuard;
use akode_arg0::arg0_dispatch;
use tempfile::TempDir;
pub struct TestBinaryDispatchGuard {
_codex_home: TempDir,
arg0: Arg0PathEntryGuard,
_previous_codex_home: Option<std::ffi::OsString>,
}
impl TestBinaryDispatchGuard {
pub fn paths(&self) -> &Arg0DispatchPaths {
self.arg0.paths()
}
}
pub enum TestBinaryDispatchMode {
DispatchArg0Only,
Skip,
InstallAliases,
}
pub fn configure_test_binary_dispatch<F>(
codex_home_prefix: &str,
classify: F,
) -> Option<TestBinaryDispatchGuard>
where
F: FnOnce(&str, Option<&str>) -> TestBinaryDispatchMode,
{
let mut args = std::env::args_os();
let argv0 = args.next().unwrap_or_default();
let exe_name = Path::new(&argv0)
.file_name()
.and_then(|name| name.to_str())
.unwrap_or("");
let argv1 = args.next();
match classify(exe_name, argv1.as_deref().and_then(|arg| arg.to_str())) {
TestBinaryDispatchMode::DispatchArg0Only => {
let _ = arg0_dispatch();
None
}
TestBinaryDispatchMode::Skip => None,
TestBinaryDispatchMode::InstallAliases => {
let codex_home = match tempfile::Builder::new().prefix(codex_home_prefix).tempdir() {
Ok(codex_home) => codex_home,
Err(error) => panic!("failed to create test AKODE_HOME: {error}"),
};
let previous_codex_home = std::env::var_os("AKODE_HOME");
// Safety: this runs from a test ctor before test threads begin.
unsafe {
std::env::set_var("AKODE_HOME", codex_home.path());
}
let arg0 = match arg0_dispatch() {
Some(arg0) => arg0,
None => panic!("failed to configure arg0 dispatch aliases for test binary"),
};
match previous_codex_home.as_ref() {
Some(value) => unsafe {
std::env::set_var("AKODE_HOME", value);
},
None => unsafe {
std::env::remove_var("AKODE_HOME");
},
}
Some(TestBinaryDispatchGuard {
_codex_home: codex_home,
arg0,
_previous_codex_home: previous_codex_home,
})
}
}
}