mirror of
https://github.com/openai/codex.git
synced 2026-10-26 18:38:47 +00:00
## What changed - Use `exec_command` and `write_stdin` as the shell tool surface. - Treat legacy `default`, `local`, and `shell_command` model metadata as `unified_exec`. - Remove obsolete shell-selection configuration and runtime paths while preserving the feature and policy gates for zsh fork execution. GitOrigin-RevId: d743cbe598630d73052f1fecad680c4cde17977d
90 lines
2.4 KiB
Rust
90 lines
2.4 KiB
Rust
use codex_features::Feature;
|
|
use codex_features::Features;
|
|
use codex_protocol::config_types::ModeKind;
|
|
use pretty_assertions::assert_eq;
|
|
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn request_user_input_modes_follow_default_mode_feature() {
|
|
let mut features = Features::with_defaults();
|
|
features.disable(Feature::DefaultModeRequestUserInput);
|
|
assert_eq!(
|
|
request_user_input_available_modes(&features),
|
|
vec![ModeKind::Plan]
|
|
);
|
|
|
|
features.enable(Feature::DefaultModeRequestUserInput);
|
|
assert_eq!(
|
|
request_user_input_available_modes(&features),
|
|
vec![ModeKind::Default, ModeKind::Plan]
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn unified_exec_shell_mode_respects_feature_and_policy_gates() {
|
|
let exe = std::env::current_exe().expect("current exe path");
|
|
let shell = exe.clone();
|
|
let mut features = Features::with_defaults();
|
|
features.enable(Feature::ShellTool);
|
|
features.enable(Feature::ShellZshFork);
|
|
let mode = UnifiedExecShellMode::for_session(
|
|
&features,
|
|
ToolUserShellType::Zsh,
|
|
Some(&shell),
|
|
Some(&exe),
|
|
);
|
|
if cfg!(unix) {
|
|
assert!(matches!(mode, UnifiedExecShellMode::ZshFork(_)));
|
|
} else {
|
|
assert_eq!(mode, UnifiedExecShellMode::Direct);
|
|
}
|
|
|
|
features.disable(Feature::ShellZshFork);
|
|
assert_eq!(
|
|
UnifiedExecShellMode::for_session(
|
|
&features,
|
|
ToolUserShellType::Zsh,
|
|
Some(&shell),
|
|
Some(&exe),
|
|
),
|
|
UnifiedExecShellMode::Direct
|
|
);
|
|
|
|
features.enable(Feature::ShellZshFork);
|
|
features.disable(Feature::UnifiedExecZshFork);
|
|
assert_eq!(
|
|
UnifiedExecShellMode::for_session(
|
|
&features,
|
|
ToolUserShellType::Zsh,
|
|
Some(&shell),
|
|
Some(&exe),
|
|
),
|
|
UnifiedExecShellMode::Direct
|
|
);
|
|
|
|
features.enable(Feature::UnifiedExecZshFork);
|
|
features.disable(Feature::UnifiedExec);
|
|
assert_eq!(
|
|
UnifiedExecShellMode::for_session(
|
|
&features,
|
|
ToolUserShellType::Zsh,
|
|
Some(&shell),
|
|
Some(&exe),
|
|
),
|
|
UnifiedExecShellMode::Direct
|
|
);
|
|
|
|
features.enable(Feature::UnifiedExec);
|
|
features.disable(Feature::ShellTool);
|
|
assert_eq!(
|
|
UnifiedExecShellMode::for_session(
|
|
&features,
|
|
ToolUserShellType::Zsh,
|
|
Some(&shell),
|
|
Some(&exe),
|
|
),
|
|
UnifiedExecShellMode::Direct
|
|
);
|
|
}
|