mirror of
https://github.com/openai/codex.git
synced 2026-11-06 20:20:34 +00:00
Fix cross-platform shell approval fixtures
This commit is contained in:
@@ -22,6 +22,7 @@ use codex_protocol::protocol::RolloutItem;
|
||||
use codex_protocol::protocol::RolloutLine;
|
||||
use codex_protocol::user_input::UserInput;
|
||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
use core_test_support::TestTargetOs;
|
||||
use core_test_support::hooks::trust_discovered_hooks;
|
||||
use core_test_support::hooks::trust_hooks;
|
||||
use core_test_support::managed_network_requirements_loader;
|
||||
@@ -43,6 +44,7 @@ use core_test_support::skip_if_no_network;
|
||||
use core_test_support::streaming_sse::StreamingSseChunk;
|
||||
use core_test_support::streaming_sse::start_streaming_sse_server;
|
||||
use core_test_support::test_codex::test_codex;
|
||||
use core_test_support::test_target_os;
|
||||
use core_test_support::wait_for_event;
|
||||
use pretty_assertions::assert_eq;
|
||||
use serde_json::Value;
|
||||
@@ -4017,10 +4019,16 @@ async fn post_tool_use_blocks_when_exec_session_completes_via_write_stdin() -> R
|
||||
let server = start_mock_server().await;
|
||||
let start_call_id = "posttooluse-exec-session-start";
|
||||
let poll_call_id = "posttooluse-exec-session-poll";
|
||||
let command = "sleep 1; printf session-post-hook-output".to_string();
|
||||
let command = match test_target_os() {
|
||||
TestTargetOs::Linux | TestTargetOs::MacOs => {
|
||||
"sleep 1; printf session-post-hook-output".to_string()
|
||||
}
|
||||
TestTargetOs::Windows => {
|
||||
"Start-Sleep -Seconds 1; [Console]::Write('session-post-hook-output')".to_string()
|
||||
}
|
||||
};
|
||||
let start_args = serde_json::json!({
|
||||
"cmd": command,
|
||||
"shell": "/bin/sh",
|
||||
"login": false,
|
||||
"tty": false,
|
||||
"yield_time_ms": 250,
|
||||
|
||||
@@ -253,15 +253,19 @@ async fn compatible_remote_path_hint_uses_environment_shell_in_remote_cwd() -> R
|
||||
|
||||
skip_if_no_remote_env!(Ok(()));
|
||||
|
||||
let (shell, expected_cwd_prefix) = match test_target_os() {
|
||||
TestTargetOs::Linux => ("/attacker/bash", "/tmp/codex-core-test-cwd-"),
|
||||
TestTargetOs::Windows => (r"C:\attacker\PowerShell.ExE", r"C:\codex-core-test-cwd-"),
|
||||
let (shell, command, expected_cwd_prefix) = match test_target_os() {
|
||||
TestTargetOs::Linux => ("/attacker/bash", "pwd", "/tmp/codex-core-test-cwd-"),
|
||||
TestTargetOs::Windows => (
|
||||
r"C:\attacker\PowerShell.ExE",
|
||||
"Write-Output (Get-Location).Path",
|
||||
r"C:\codex-core-test-cwd-",
|
||||
),
|
||||
TestTargetOs::MacOs => unreachable!("remote test targets do not run macOS"),
|
||||
};
|
||||
|
||||
let server = start_mock_server().await;
|
||||
let arguments = serde_json::to_string(&json!({
|
||||
"cmd": "pwd",
|
||||
"cmd": command,
|
||||
"shell": shell,
|
||||
"login": false,
|
||||
"yield_time_ms": 10_000,
|
||||
|
||||
@@ -408,7 +408,6 @@ async fn unified_exec_emits_exec_command_begin_event() -> Result<()> {
|
||||
|
||||
let call_id = "uexec-begin-event";
|
||||
let args = json!({
|
||||
"shell": "bash".to_string(),
|
||||
"cmd": "/bin/echo hello unified exec".to_string(),
|
||||
"yield_time_ms": 250,
|
||||
});
|
||||
@@ -1298,7 +1297,6 @@ async fn unified_exec_emits_one_begin_and_one_end_event() -> Result<()> {
|
||||
|
||||
let open_call_id = "uexec-open-session";
|
||||
let open_args = json!({
|
||||
"shell": "bash".to_string(),
|
||||
"cmd": "sleep 0.1".to_string(),
|
||||
"yield_time_ms": 10,
|
||||
});
|
||||
@@ -2038,7 +2036,7 @@ async fn model_shell_resolution_failure_precedes_process_allocation_and_events()
|
||||
.enable(Feature::UnifiedExec)
|
||||
.expect("test config should allow feature update");
|
||||
});
|
||||
let test = builder.build_with_auto_env(&server).await?;
|
||||
let test = builder.build(&server).await?;
|
||||
|
||||
let invalid_call_id = "uexec-missing-model-shell";
|
||||
let invalid_args = serde_json::json!({
|
||||
|
||||
@@ -117,10 +117,10 @@ pub fn detect_shell_type(shell_path: impl AsRef<std::path::Path>) -> Option<Shel
|
||||
let shell_path = shell_path.as_ref();
|
||||
#[cfg(windows)]
|
||||
{
|
||||
return shell_path
|
||||
shell_path
|
||||
.as_os_str()
|
||||
.to_str()
|
||||
.and_then(detect_shell_type_from_hint);
|
||||
.and_then(detect_shell_type_from_hint)
|
||||
}
|
||||
#[cfg(not(windows))]
|
||||
match shell_path.as_os_str().to_str() {
|
||||
|
||||
Reference in New Issue
Block a user