Files
imeai-aKode/akode-rs/core/tests/suite/deprecation_notice.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

225 lines
7.6 KiB
Rust

#![cfg(not(target_os = "windows"))]
use anyhow::Ok;
use akode_config::test_support::ManagedConfigFixture;
use akode_features::Feature;
use akode_protocol::protocol::DeprecationNoticeEvent;
use akode_protocol::protocol::EventMsg;
use core_test_support::responses;
use core_test_support::responses::start_mock_server;
use core_test_support::skip_if_no_network;
use core_test_support::test_codex::TestCodex;
use core_test_support::test_codex::test_codex;
use core_test_support::wait_for_event_match;
use pretty_assertions::assert_eq;
use std::collections::BTreeMap;
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn emits_deprecation_notice_for_legacy_feature_flag() -> anyhow::Result<()> {
skip_if_no_network!(Ok(()));
let server = start_mock_server().await;
let mut builder = test_codex().with_config(|config| {
let mut features = config.features.get().clone();
features
.record_legacy_usage_force("use_experimental_unified_exec_tool", Feature::UnifiedExec);
config
.features
.set(features)
.expect("test config should allow managed feature metadata updates");
});
let TestCodex { codex, .. } = builder.build(&server).await?;
let notice = wait_for_event_match(&codex, |event| match event {
EventMsg::DeprecationNotice(ev) => Some(ev.clone()),
_ => None,
})
.await;
let DeprecationNoticeEvent { summary, details } = notice;
assert_eq!(
summary,
"`[features].use_experimental_unified_exec_tool` is deprecated. Use `[features].unified_exec` instead.".to_string(),
);
assert_eq!(
details.as_deref(),
Some(
"Enable it with `--enable unified_exec` or `[features].unified_exec` in config.toml. See https://developers.openai.com/codex/config-basic#feature-flags for details."
),
);
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn emits_deprecation_notice_for_web_search_feature_flag_values() -> anyhow::Result<()> {
skip_if_no_network!(Ok(()));
for enabled in [true, false] {
let server = start_mock_server().await;
let mut builder = test_codex().with_config(move |config| {
let mut entries = BTreeMap::new();
entries.insert("web_search_request".to_string(), enabled);
let mut features = config.features.get().clone();
features.apply_map(&entries);
config
.features
.set(features)
.expect("test config should allow managed feature map updates");
});
let TestCodex { codex, .. } = builder.build(&server).await?;
let notice = wait_for_event_match(&codex, |event| match event {
EventMsg::DeprecationNotice(ev)
if ev.summary.contains("[features].web_search_request") =>
{
Some(ev.clone())
}
_ => None,
})
.await;
let DeprecationNoticeEvent { summary, details } = notice;
assert_eq!(
summary,
"`[features].web_search_request` is deprecated because web search is enabled by default."
.to_string(),
);
assert_eq!(
details.as_deref(),
Some(
"Set `web_search` to `\"live\"`, `\"indexed\"`, `\"cached\"`, or `\"disabled\"` at the top level (or under a profile) in config.toml if you want to override it."
),
);
}
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn emits_deprecation_notice_for_use_legacy_landlock() -> anyhow::Result<()> {
skip_if_no_network!(Ok(()));
let server = start_mock_server().await;
let mut builder = test_codex().with_config(|config| {
let mut entries = BTreeMap::new();
entries.insert("use_legacy_landlock".to_string(), true);
let mut features = config.features.get().clone();
features.apply_map(&entries);
config
.features
.set(features)
.expect("test config should allow managed feature map updates");
});
let TestCodex { codex, .. } = builder.build(&server).await?;
let notice = wait_for_event_match(&codex, |event| match event {
EventMsg::DeprecationNotice(ev)
if ev.summary.contains("[features].use_legacy_landlock") =>
{
Some(ev.clone())
}
_ => None,
})
.await;
let DeprecationNoticeEvent { summary, details } = notice;
assert_eq!(
summary,
"`[features].use_legacy_landlock` is deprecated and will be removed soon.".to_string(),
);
assert_eq!(
details.as_deref(),
Some("Remove this setting to stop opting into the legacy Linux sandbox behavior."),
);
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn legacy_zsh_config_starts_session_with_migration_notices() -> anyhow::Result<()> {
skip_if_no_network!(Ok(()));
let server = start_mock_server().await;
let mut builder = test_codex()
.with_pre_build_hook(|home| {
std::fs::write(
home.join("config.toml"),
r#"[features]
shell_zsh_fork = true
unified_exec_zsh_fork = true
"#,
)
.expect("write legacy configuration");
})
.with_managed_config(ManagedConfigFixture::requirements(
"[features]\nshell_zsh_fork = true\nunified_exec_zsh_fork = true\n",
));
let test = builder.build_with_auto_env(&server).await?;
for feature in ["shell_zsh_fork", "unified_exec_zsh_fork"] {
let expected = DeprecationNoticeEvent {
summary: format!("`[features].{feature}` is deprecated and ignored."),
details: Some(format!(
"The patched zsh backend has been removed. Shell commands now use the standard shell executor. Remove `{feature}` from [features] in config.toml or profile configuration files."
)),
};
let notice = wait_for_event_match(&test.codex, |event| match event {
EventMsg::DeprecationNotice(notice) if notice.summary == expected.summary => {
Some(notice.clone())
}
_ => None,
})
.await;
assert_eq!(
(notice.summary, notice.details),
(expected.summary, expected.details)
);
}
let shell = match core_test_support::test_target_os() {
core_test_support::TestTargetOs::Linux | core_test_support::TestTargetOs::MacOs => {
"/bin/sh"
}
core_test_support::TestTargetOs::Windows => "powershell",
};
let arguments = serde_json::json!({
"cmd": "echo migrated-shell",
"shell": shell,
"login": false,
"yield_time_ms": 10_000,
});
let mock = responses::mount_sse_sequence(
&server,
vec![
responses::sse(vec![
responses::ev_function_call(
"shell-migration",
"exec_command",
&arguments.to_string(),
),
responses::ev_completed("response-1"),
]),
responses::sse(vec![responses::ev_completed("response-2")]),
],
)
.await;
test.submit_turn("run a command with the configured shell")
.await?;
let output = mock
.function_call_output_text("shell-migration")
.expect("shell tool output");
assert!(output.contains("Process exited with code 0\n"), "{output}");
assert_eq!(
output
.split_once("Output:\n")
.map(|(_, stdout)| stdout.trim()),
Some("migrated-shell")
);
Ok(())
}