From 14cd9939505df4d0f3f3dc91e268a96d11b0631a Mon Sep 17 00:00:00 2001 From: Dylan Hurd Date: Wed, 18 Feb 2026 08:59:14 -0800 Subject: [PATCH] clean up scenario tests --- .../.gitattributes | 1 + .../expected/sample.txt | 2 ++ .../input/sample.txt | 2 ++ .../patch.txt | 7 ++++ .../.gitattributes | 1 + .../expected/created.txt | 2 ++ .../patch.txt | 5 +++ .../.gitattributes | 1 + .../expected/lines.txt | 2 ++ .../input/lines.txt | 3 ++ .../patch.txt | 7 ++++ .../.gitattributes | 1 + .../expected/old/other.txt | 1 + .../expected/renamed/dir/name.txt | 2 ++ .../input/old/name.txt | 2 ++ .../input/old/other.txt | 1 + .../patch.txt | 8 +++++ .../.gitattributes | 1 + .../expected/multi.txt | 4 +++ .../input/multi.txt | 4 +++ .../patch.txt | 9 +++++ codex-rs/apply-patch/tests/suite/scenarios.rs | 35 ------------------- 22 files changed, 66 insertions(+), 35 deletions(-) create mode 100644 codex-rs/apply-patch/tests/fixtures/scenarios/023_preserves_crlf_for_update_hunks/.gitattributes create mode 100644 codex-rs/apply-patch/tests/fixtures/scenarios/023_preserves_crlf_for_update_hunks/expected/sample.txt create mode 100644 codex-rs/apply-patch/tests/fixtures/scenarios/023_preserves_crlf_for_update_hunks/input/sample.txt create mode 100644 codex-rs/apply-patch/tests/fixtures/scenarios/023_preserves_crlf_for_update_hunks/patch.txt create mode 100644 codex-rs/apply-patch/tests/fixtures/scenarios/024_preserves_crlf_for_add_file_hunks/.gitattributes create mode 100644 codex-rs/apply-patch/tests/fixtures/scenarios/024_preserves_crlf_for_add_file_hunks/expected/created.txt create mode 100644 codex-rs/apply-patch/tests/fixtures/scenarios/024_preserves_crlf_for_add_file_hunks/patch.txt create mode 100644 codex-rs/apply-patch/tests/fixtures/scenarios/025_preserves_crlf_for_deletion_only_hunk/.gitattributes create mode 100644 codex-rs/apply-patch/tests/fixtures/scenarios/025_preserves_crlf_for_deletion_only_hunk/expected/lines.txt create mode 100644 codex-rs/apply-patch/tests/fixtures/scenarios/025_preserves_crlf_for_deletion_only_hunk/input/lines.txt create mode 100644 codex-rs/apply-patch/tests/fixtures/scenarios/025_preserves_crlf_for_deletion_only_hunk/patch.txt create mode 100644 codex-rs/apply-patch/tests/fixtures/scenarios/026_preserves_crlf_for_move_update_hunk/.gitattributes create mode 100644 codex-rs/apply-patch/tests/fixtures/scenarios/026_preserves_crlf_for_move_update_hunk/expected/old/other.txt create mode 100644 codex-rs/apply-patch/tests/fixtures/scenarios/026_preserves_crlf_for_move_update_hunk/expected/renamed/dir/name.txt create mode 100644 codex-rs/apply-patch/tests/fixtures/scenarios/026_preserves_crlf_for_move_update_hunk/input/old/name.txt create mode 100644 codex-rs/apply-patch/tests/fixtures/scenarios/026_preserves_crlf_for_move_update_hunk/input/old/other.txt create mode 100644 codex-rs/apply-patch/tests/fixtures/scenarios/026_preserves_crlf_for_move_update_hunk/patch.txt create mode 100644 codex-rs/apply-patch/tests/fixtures/scenarios/027_preserves_crlf_for_multiple_chunks/.gitattributes create mode 100644 codex-rs/apply-patch/tests/fixtures/scenarios/027_preserves_crlf_for_multiple_chunks/expected/multi.txt create mode 100644 codex-rs/apply-patch/tests/fixtures/scenarios/027_preserves_crlf_for_multiple_chunks/input/multi.txt create mode 100644 codex-rs/apply-patch/tests/fixtures/scenarios/027_preserves_crlf_for_multiple_chunks/patch.txt diff --git a/codex-rs/apply-patch/tests/fixtures/scenarios/023_preserves_crlf_for_update_hunks/.gitattributes b/codex-rs/apply-patch/tests/fixtures/scenarios/023_preserves_crlf_for_update_hunks/.gitattributes new file mode 100644 index 0000000000..fa1385d99a --- /dev/null +++ b/codex-rs/apply-patch/tests/fixtures/scenarios/023_preserves_crlf_for_update_hunks/.gitattributes @@ -0,0 +1 @@ +* -text diff --git a/codex-rs/apply-patch/tests/fixtures/scenarios/023_preserves_crlf_for_update_hunks/expected/sample.txt b/codex-rs/apply-patch/tests/fixtures/scenarios/023_preserves_crlf_for_update_hunks/expected/sample.txt new file mode 100644 index 0000000000..87a02e2e58 --- /dev/null +++ b/codex-rs/apply-patch/tests/fixtures/scenarios/023_preserves_crlf_for_update_hunks/expected/sample.txt @@ -0,0 +1,2 @@ +uno +two diff --git a/codex-rs/apply-patch/tests/fixtures/scenarios/023_preserves_crlf_for_update_hunks/input/sample.txt b/codex-rs/apply-patch/tests/fixtures/scenarios/023_preserves_crlf_for_update_hunks/input/sample.txt new file mode 100644 index 0000000000..4e349b596c --- /dev/null +++ b/codex-rs/apply-patch/tests/fixtures/scenarios/023_preserves_crlf_for_update_hunks/input/sample.txt @@ -0,0 +1,2 @@ +one +two diff --git a/codex-rs/apply-patch/tests/fixtures/scenarios/023_preserves_crlf_for_update_hunks/patch.txt b/codex-rs/apply-patch/tests/fixtures/scenarios/023_preserves_crlf_for_update_hunks/patch.txt new file mode 100644 index 0000000000..f6ce3b0a4b --- /dev/null +++ b/codex-rs/apply-patch/tests/fixtures/scenarios/023_preserves_crlf_for_update_hunks/patch.txt @@ -0,0 +1,7 @@ +*** Begin Patch +*** Update File: sample.txt +@@ +-one ++uno + two +*** End Patch diff --git a/codex-rs/apply-patch/tests/fixtures/scenarios/024_preserves_crlf_for_add_file_hunks/.gitattributes b/codex-rs/apply-patch/tests/fixtures/scenarios/024_preserves_crlf_for_add_file_hunks/.gitattributes new file mode 100644 index 0000000000..fa1385d99a --- /dev/null +++ b/codex-rs/apply-patch/tests/fixtures/scenarios/024_preserves_crlf_for_add_file_hunks/.gitattributes @@ -0,0 +1 @@ +* -text diff --git a/codex-rs/apply-patch/tests/fixtures/scenarios/024_preserves_crlf_for_add_file_hunks/expected/created.txt b/codex-rs/apply-patch/tests/fixtures/scenarios/024_preserves_crlf_for_add_file_hunks/expected/created.txt new file mode 100644 index 0000000000..23eb407b64 --- /dev/null +++ b/codex-rs/apply-patch/tests/fixtures/scenarios/024_preserves_crlf_for_add_file_hunks/expected/created.txt @@ -0,0 +1,2 @@ +hello +world diff --git a/codex-rs/apply-patch/tests/fixtures/scenarios/024_preserves_crlf_for_add_file_hunks/patch.txt b/codex-rs/apply-patch/tests/fixtures/scenarios/024_preserves_crlf_for_add_file_hunks/patch.txt new file mode 100644 index 0000000000..f3c9f7f8c2 --- /dev/null +++ b/codex-rs/apply-patch/tests/fixtures/scenarios/024_preserves_crlf_for_add_file_hunks/patch.txt @@ -0,0 +1,5 @@ +*** Begin Patch +*** Add File: created.txt ++hello ++world +*** End Patch diff --git a/codex-rs/apply-patch/tests/fixtures/scenarios/025_preserves_crlf_for_deletion_only_hunk/.gitattributes b/codex-rs/apply-patch/tests/fixtures/scenarios/025_preserves_crlf_for_deletion_only_hunk/.gitattributes new file mode 100644 index 0000000000..fa1385d99a --- /dev/null +++ b/codex-rs/apply-patch/tests/fixtures/scenarios/025_preserves_crlf_for_deletion_only_hunk/.gitattributes @@ -0,0 +1 @@ +* -text diff --git a/codex-rs/apply-patch/tests/fixtures/scenarios/025_preserves_crlf_for_deletion_only_hunk/expected/lines.txt b/codex-rs/apply-patch/tests/fixtures/scenarios/025_preserves_crlf_for_deletion_only_hunk/expected/lines.txt new file mode 100644 index 0000000000..bc7f1d41b2 --- /dev/null +++ b/codex-rs/apply-patch/tests/fixtures/scenarios/025_preserves_crlf_for_deletion_only_hunk/expected/lines.txt @@ -0,0 +1,2 @@ +first +third diff --git a/codex-rs/apply-patch/tests/fixtures/scenarios/025_preserves_crlf_for_deletion_only_hunk/input/lines.txt b/codex-rs/apply-patch/tests/fixtures/scenarios/025_preserves_crlf_for_deletion_only_hunk/input/lines.txt new file mode 100644 index 0000000000..2e11fe5aa8 --- /dev/null +++ b/codex-rs/apply-patch/tests/fixtures/scenarios/025_preserves_crlf_for_deletion_only_hunk/input/lines.txt @@ -0,0 +1,3 @@ +first +second +third diff --git a/codex-rs/apply-patch/tests/fixtures/scenarios/025_preserves_crlf_for_deletion_only_hunk/patch.txt b/codex-rs/apply-patch/tests/fixtures/scenarios/025_preserves_crlf_for_deletion_only_hunk/patch.txt new file mode 100644 index 0000000000..b4b0b74a64 --- /dev/null +++ b/codex-rs/apply-patch/tests/fixtures/scenarios/025_preserves_crlf_for_deletion_only_hunk/patch.txt @@ -0,0 +1,7 @@ +*** Begin Patch +*** Update File: lines.txt +@@ + first +-second + third +*** End Patch diff --git a/codex-rs/apply-patch/tests/fixtures/scenarios/026_preserves_crlf_for_move_update_hunk/.gitattributes b/codex-rs/apply-patch/tests/fixtures/scenarios/026_preserves_crlf_for_move_update_hunk/.gitattributes new file mode 100644 index 0000000000..fa1385d99a --- /dev/null +++ b/codex-rs/apply-patch/tests/fixtures/scenarios/026_preserves_crlf_for_move_update_hunk/.gitattributes @@ -0,0 +1 @@ +* -text diff --git a/codex-rs/apply-patch/tests/fixtures/scenarios/026_preserves_crlf_for_move_update_hunk/expected/old/other.txt b/codex-rs/apply-patch/tests/fixtures/scenarios/026_preserves_crlf_for_move_update_hunk/expected/old/other.txt new file mode 100644 index 0000000000..4f5ee50185 --- /dev/null +++ b/codex-rs/apply-patch/tests/fixtures/scenarios/026_preserves_crlf_for_move_update_hunk/expected/old/other.txt @@ -0,0 +1 @@ +keep diff --git a/codex-rs/apply-patch/tests/fixtures/scenarios/026_preserves_crlf_for_move_update_hunk/expected/renamed/dir/name.txt b/codex-rs/apply-patch/tests/fixtures/scenarios/026_preserves_crlf_for_move_update_hunk/expected/renamed/dir/name.txt new file mode 100644 index 0000000000..86688d945e --- /dev/null +++ b/codex-rs/apply-patch/tests/fixtures/scenarios/026_preserves_crlf_for_move_update_hunk/expected/renamed/dir/name.txt @@ -0,0 +1,2 @@ +new +line diff --git a/codex-rs/apply-patch/tests/fixtures/scenarios/026_preserves_crlf_for_move_update_hunk/input/old/name.txt b/codex-rs/apply-patch/tests/fixtures/scenarios/026_preserves_crlf_for_move_update_hunk/input/old/name.txt new file mode 100644 index 0000000000..8bd7378255 --- /dev/null +++ b/codex-rs/apply-patch/tests/fixtures/scenarios/026_preserves_crlf_for_move_update_hunk/input/old/name.txt @@ -0,0 +1,2 @@ +old +line diff --git a/codex-rs/apply-patch/tests/fixtures/scenarios/026_preserves_crlf_for_move_update_hunk/input/old/other.txt b/codex-rs/apply-patch/tests/fixtures/scenarios/026_preserves_crlf_for_move_update_hunk/input/old/other.txt new file mode 100644 index 0000000000..4f5ee50185 --- /dev/null +++ b/codex-rs/apply-patch/tests/fixtures/scenarios/026_preserves_crlf_for_move_update_hunk/input/old/other.txt @@ -0,0 +1 @@ +keep diff --git a/codex-rs/apply-patch/tests/fixtures/scenarios/026_preserves_crlf_for_move_update_hunk/patch.txt b/codex-rs/apply-patch/tests/fixtures/scenarios/026_preserves_crlf_for_move_update_hunk/patch.txt new file mode 100644 index 0000000000..de1bb6c1b0 --- /dev/null +++ b/codex-rs/apply-patch/tests/fixtures/scenarios/026_preserves_crlf_for_move_update_hunk/patch.txt @@ -0,0 +1,8 @@ +*** Begin Patch +*** Update File: old/name.txt +*** Move to: renamed/dir/name.txt +@@ +-old ++new + line +*** End Patch diff --git a/codex-rs/apply-patch/tests/fixtures/scenarios/027_preserves_crlf_for_multiple_chunks/.gitattributes b/codex-rs/apply-patch/tests/fixtures/scenarios/027_preserves_crlf_for_multiple_chunks/.gitattributes new file mode 100644 index 0000000000..fa1385d99a --- /dev/null +++ b/codex-rs/apply-patch/tests/fixtures/scenarios/027_preserves_crlf_for_multiple_chunks/.gitattributes @@ -0,0 +1 @@ +* -text diff --git a/codex-rs/apply-patch/tests/fixtures/scenarios/027_preserves_crlf_for_multiple_chunks/expected/multi.txt b/codex-rs/apply-patch/tests/fixtures/scenarios/027_preserves_crlf_for_multiple_chunks/expected/multi.txt new file mode 100644 index 0000000000..381acb9027 --- /dev/null +++ b/codex-rs/apply-patch/tests/fixtures/scenarios/027_preserves_crlf_for_multiple_chunks/expected/multi.txt @@ -0,0 +1,4 @@ +one +dos +three +cuatro diff --git a/codex-rs/apply-patch/tests/fixtures/scenarios/027_preserves_crlf_for_multiple_chunks/input/multi.txt b/codex-rs/apply-patch/tests/fixtures/scenarios/027_preserves_crlf_for_multiple_chunks/input/multi.txt new file mode 100644 index 0000000000..7fbf4d847b --- /dev/null +++ b/codex-rs/apply-patch/tests/fixtures/scenarios/027_preserves_crlf_for_multiple_chunks/input/multi.txt @@ -0,0 +1,4 @@ +one +two +three +four diff --git a/codex-rs/apply-patch/tests/fixtures/scenarios/027_preserves_crlf_for_multiple_chunks/patch.txt b/codex-rs/apply-patch/tests/fixtures/scenarios/027_preserves_crlf_for_multiple_chunks/patch.txt new file mode 100644 index 0000000000..8d51e90d7e --- /dev/null +++ b/codex-rs/apply-patch/tests/fixtures/scenarios/027_preserves_crlf_for_multiple_chunks/patch.txt @@ -0,0 +1,9 @@ +*** Begin Patch +*** Update File: multi.txt +@@ +-two ++dos +@@ +-four ++cuatro +*** End Patch diff --git a/codex-rs/apply-patch/tests/suite/scenarios.rs b/codex-rs/apply-patch/tests/suite/scenarios.rs index 5f8285b931..3beb7d652d 100644 --- a/codex-rs/apply-patch/tests/suite/scenarios.rs +++ b/codex-rs/apply-patch/tests/suite/scenarios.rs @@ -124,38 +124,3 @@ fn copy_dir_recursive(src: &Path, dst: &Path) -> anyhow::Result<()> { } Ok(()) } - -#[test] -fn test_apply_patch_preserves_crlf_for_update_hunks() -> anyhow::Result<()> { - let tmp = tempdir()?; - let file_path = tmp.path().join("sample.txt"); - fs::write(&file_path, b"one\r\ntwo\r\n")?; - - let patch = "*** Begin Patch\r\n*** Update File: sample.txt\r\n@@\r\n-one\r\n+uno\r\n two\r\n*** End Patch\r\n"; - - Command::new(codex_utils_cargo_bin::cargo_bin("apply_patch")?) - .arg(patch) - .current_dir(tmp.path()) - .output()?; - - assert_eq!(fs::read(&file_path)?, b"uno\r\ntwo\r\n"); - Ok(()) -} - -#[test] -fn test_apply_patch_preserves_crlf_for_add_file_hunks() -> anyhow::Result<()> { - let tmp = tempdir()?; - let patch = - "*** Begin Patch\r\n*** Add File: created.txt\r\n+hello\r\n+world\r\n*** End Patch\r\n"; - - Command::new(codex_utils_cargo_bin::cargo_bin("apply_patch")?) - .arg(patch) - .current_dir(tmp.path()) - .output()?; - - assert_eq!( - fs::read(tmp.path().join("created.txt"))?, - b"hello\r\nworld\r\n" - ); - Ok(()) -}