|
| 1 | +#![cfg(not(target_os = "windows"))] |
| 2 | +#![allow(clippy::expect_used, clippy::unwrap_used)] |
| 3 | + |
| 4 | +use core_test_support::responses; |
| 5 | +use core_test_support::test_codex_exec::test_codex_exec; |
| 6 | + |
| 7 | +/// Verify that the --add-dir flag is accepted and the command runs successfully. |
| 8 | +/// This test confirms the CLI argument is properly wired up. |
| 9 | +#[tokio::test(flavor = "multi_thread", worker_threads = 1)] |
| 10 | +async fn accepts_add_dir_flag() -> anyhow::Result<()> { |
| 11 | + let test = test_codex_exec(); |
| 12 | + |
| 13 | + let server = responses::start_mock_server().await; |
| 14 | + let body = responses::sse(vec![ |
| 15 | + responses::ev_response_created("response_1"), |
| 16 | + responses::ev_assistant_message("response_1", "Task completed"), |
| 17 | + responses::ev_completed("response_1"), |
| 18 | + ]); |
| 19 | + responses::mount_sse_once(&server, body).await; |
| 20 | + |
| 21 | + // Create temporary directories to use with --add-dir |
| 22 | + let temp_dir1 = tempfile::tempdir()?; |
| 23 | + let temp_dir2 = tempfile::tempdir()?; |
| 24 | + |
| 25 | + test.cmd_with_server(&server) |
| 26 | + .arg("--skip-git-repo-check") |
| 27 | + .arg("--sandbox") |
| 28 | + .arg("workspace-write") |
| 29 | + .arg("--add-dir") |
| 30 | + .arg(temp_dir1.path()) |
| 31 | + .arg("--add-dir") |
| 32 | + .arg(temp_dir2.path()) |
| 33 | + .arg("test with additional directories") |
| 34 | + .assert() |
| 35 | + .code(0); |
| 36 | + |
| 37 | + Ok(()) |
| 38 | +} |
| 39 | + |
| 40 | +/// Verify that multiple --add-dir flags can be specified. |
| 41 | +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] |
| 42 | +async fn accepts_multiple_add_dir_flags() -> anyhow::Result<()> { |
| 43 | + let test = test_codex_exec(); |
| 44 | + |
| 45 | + let server = responses::start_mock_server().await; |
| 46 | + let body = responses::sse(vec![ |
| 47 | + responses::ev_response_created("response_1"), |
| 48 | + responses::ev_assistant_message("response_1", "Multiple directories accepted"), |
| 49 | + responses::ev_completed("response_1"), |
| 50 | + ]); |
| 51 | + responses::mount_sse_once(&server, body).await; |
| 52 | + |
| 53 | + let temp_dir1 = tempfile::tempdir()?; |
| 54 | + let temp_dir2 = tempfile::tempdir()?; |
| 55 | + let temp_dir3 = tempfile::tempdir()?; |
| 56 | + |
| 57 | + test.cmd_with_server(&server) |
| 58 | + .arg("--skip-git-repo-check") |
| 59 | + .arg("--sandbox") |
| 60 | + .arg("workspace-write") |
| 61 | + .arg("--add-dir") |
| 62 | + .arg(temp_dir1.path()) |
| 63 | + .arg("--add-dir") |
| 64 | + .arg(temp_dir2.path()) |
| 65 | + .arg("--add-dir") |
| 66 | + .arg(temp_dir3.path()) |
| 67 | + .arg("test with three directories") |
| 68 | + .assert() |
| 69 | + .code(0); |
| 70 | + |
| 71 | + Ok(()) |
| 72 | +} |
0 commit comments