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>
This commit is contained in:
47
akode-rs/exec-server/testing/BUILD.bazel
Normal file
47
akode-rs/exec-server/testing/BUILD.bazel
Normal file
@@ -0,0 +1,47 @@
|
||||
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library")
|
||||
|
||||
rust_library(
|
||||
name = "wine-exec-server-test-support",
|
||||
testonly = True,
|
||||
srcs = ["wine_exec_server.rs"],
|
||||
crate_name = "wine_exec_server_test_support",
|
||||
crate_root = "wine_exec_server.rs",
|
||||
target_compatible_with = ["@platforms//os:linux"],
|
||||
visibility = ["//akode-rs/core/tests/remote_env_windows:__pkg__"],
|
||||
deps = [
|
||||
"//bazel/rules/testing/wine:wine_test_support",
|
||||
"//akode-rs/utils/cargo-bin",
|
||||
"@crates//:anyhow",
|
||||
"@crates//:tokio",
|
||||
],
|
||||
)
|
||||
|
||||
rust_binary(
|
||||
name = "wine-exec-test-runner",
|
||||
testonly = True,
|
||||
srcs = ["wine_remote_test_runner.rs"],
|
||||
crate_name = "wine_exec_test_runner",
|
||||
crate_root = "wine_remote_test_runner.rs",
|
||||
target_compatible_with = ["@platforms//os:linux"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
":wine-exec-server-test-support",
|
||||
"@crates//:anyhow",
|
||||
"@crates//:tokio",
|
||||
],
|
||||
)
|
||||
|
||||
rust_binary(
|
||||
name = "exec-server",
|
||||
testonly = True,
|
||||
srcs = ["exec_server.rs"],
|
||||
crate_name = "exec_server",
|
||||
crate_root = "exec_server.rs",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//akode-rs/exec-server",
|
||||
"//akode-rs/http-client",
|
||||
"//akode-rs/utils/pty",
|
||||
"@crates//:tokio",
|
||||
],
|
||||
)
|
||||
5
akode-rs/exec-server/testing/README.md
Normal file
5
akode-rs/exec-server/testing/README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# Windows exec-server fixture
|
||||
|
||||
This directory contains the small Windows exec-server binary used by
|
||||
foreign-OS tests. It links only `akode-exec-server` because the full Codex
|
||||
Windows graph does not yet cross-build with Bazel.
|
||||
40
akode-rs/exec-server/testing/exec_server.rs
Normal file
40
akode-rs/exec-server/testing/exec_server.rs
Normal file
@@ -0,0 +1,40 @@
|
||||
//! Minimal exec-server fixture for Bazel-only integration tests.
|
||||
//!
|
||||
//! Linking only exec-server avoids depending on the full Codex CLI binary
|
||||
//! when a test only needs a WebSocket executor endpoint. It handles the arg0
|
||||
//! helper mode because sandboxed process requests re-exec this binary.
|
||||
|
||||
use akode_exec_server::ExecServerRuntimeOptions;
|
||||
use akode_http_client::HttpClientFactory;
|
||||
use akode_http_client::OutboundProxyPolicy;
|
||||
use std::ffi::OsStr;
|
||||
|
||||
const AKODE_LINUX_SANDBOX_EXE_ENV_VAR: &str = "AKODE_TEST_LINUX_SANDBOX_EXE";
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||
#[cfg(target_os = "linux")]
|
||||
akode_utils_pty::init_spawn_helper(std::env::args_os());
|
||||
let mut args = std::env::args_os();
|
||||
let _ = args.next();
|
||||
let argv1 = args.next();
|
||||
#[cfg(unix)]
|
||||
if argv1.as_deref() == Some(OsStr::new(akode_exec_server::AKODE_ARG0_EXEC_HELPER_ARG1)) {
|
||||
akode_exec_server::run_arg0_exec_helper_main();
|
||||
}
|
||||
if argv1.as_deref() == Some(OsStr::new(akode_exec_server::AKODE_FS_HELPER_ARG1)) {
|
||||
akode_exec_server::run_fs_helper_main();
|
||||
}
|
||||
|
||||
let current_exe = std::env::current_exe()?;
|
||||
let codex_linux_sandbox_exe =
|
||||
std::env::var_os(AKODE_LINUX_SANDBOX_EXE_ENV_VAR).map(std::path::PathBuf::from);
|
||||
let runtime_paths = ExecServerRuntimeOptions::new(current_exe, codex_linux_sandbox_exe)?;
|
||||
tokio::runtime::Builder::new_multi_thread()
|
||||
.enable_all()
|
||||
.build()?
|
||||
.block_on(akode_exec_server::run_main(
|
||||
"ws://127.0.0.1:0",
|
||||
runtime_paths,
|
||||
HttpClientFactory::new(OutboundProxyPolicy::ReqwestDefault),
|
||||
))
|
||||
}
|
||||
46
akode-rs/exec-server/testing/wine_exec_server.rs
Normal file
46
akode-rs/exec-server/testing/wine_exec_server.rs
Normal file
@@ -0,0 +1,46 @@
|
||||
//! 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 = akode_utils_cargo_bin::cargo_bin("wine-windows-exec-server")?;
|
||||
let mut exec_server = WineTestCommand::new(executable)
|
||||
.env("AKODE_HOME", r"C:\akode-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
|
||||
}
|
||||
}
|
||||
65
akode-rs/exec-server/testing/wine_remote_test_runner.rs
Normal file
65
akode-rs/exec-server/testing/wine_remote_test_runner.rs
Normal file
@@ -0,0 +1,65 @@
|
||||
use std::ffi::OsStr;
|
||||
use std::ffi::OsString;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Stdio;
|
||||
|
||||
use anyhow::Context;
|
||||
use anyhow::Result;
|
||||
use tokio::process::Command;
|
||||
use wine_exec_server_test_support::WineExecServer;
|
||||
|
||||
const TEST_BINARY_ENV_VAR: &str = "AKODE_WINE_EXEC_TEST_BINARY";
|
||||
const TEST_ENVIRONMENT_ENV_VAR: &str = "AKODE_TEST_ENVIRONMENT";
|
||||
const REMOTE_EXEC_SERVER_URL_ENV_VAR: &str = "AKODE_TEST_REMOTE_EXEC_SERVER_URL";
|
||||
const LEGACY_REMOTE_ENV_ENV_VAR: &str = "AKODE_TEST_REMOTE_ENV";
|
||||
const DOCKER_CONTAINER_ENV_VAR: &str = "AKODE_TEST_REMOTE_ENV_CONTAINER_NAME";
|
||||
|
||||
#[tokio::main(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn main() -> Result<()> {
|
||||
let test_binary =
|
||||
PathBuf::from(std::env::var_os(TEST_BINARY_ENV_VAR).with_context(|| {
|
||||
format!("{TEST_BINARY_ENV_VAR} must be set by the Bazel test rule")
|
||||
})?);
|
||||
let forwarded_args = std::env::args_os().skip(1).collect::<Vec<_>>();
|
||||
|
||||
if is_terse_list_request(&forwarded_args) {
|
||||
let status = Command::new(&test_binary)
|
||||
.args(&forwarded_args)
|
||||
.status()
|
||||
.await
|
||||
.context("list integration tests")?;
|
||||
anyhow::ensure!(
|
||||
status.success(),
|
||||
"listing integration tests exited with {status}"
|
||||
);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
WineExecServer
|
||||
.scope(|exec_server_url, _wine_prefix| async move {
|
||||
let mut command = Command::new(test_binary);
|
||||
command
|
||||
.env(TEST_ENVIRONMENT_ENV_VAR, "wine-exec")
|
||||
.env(REMOTE_EXEC_SERVER_URL_ENV_VAR, exec_server_url)
|
||||
.env_remove(LEGACY_REMOTE_ENV_ENV_VAR)
|
||||
.env_remove(DOCKER_CONTAINER_ENV_VAR)
|
||||
.args(forwarded_args)
|
||||
.stdin(Stdio::null())
|
||||
.stdout(Stdio::inherit())
|
||||
.stderr(Stdio::inherit())
|
||||
.kill_on_drop(true);
|
||||
|
||||
let status = command.status().await.context("run integration tests")?;
|
||||
anyhow::ensure!(status.success(), "integration tests exited with {status}");
|
||||
Ok(())
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
fn is_terse_list_request(args: &[OsString]) -> bool {
|
||||
args.iter().map(OsString::as_os_str).eq([
|
||||
OsStr::new("--list"),
|
||||
OsStr::new("--format"),
|
||||
OsStr::new("terse"),
|
||||
])
|
||||
}
|
||||
Reference in New Issue
Block a user