mirror of
https://github.com/openai/codex.git
synced 2026-09-16 12:13:30 +00:00
clean up scenario tests
This commit is contained in:
@@ -0,0 +1 @@
|
||||
* -text
|
||||
@@ -0,0 +1,2 @@
|
||||
uno
|
||||
two
|
||||
@@ -0,0 +1,2 @@
|
||||
one
|
||||
two
|
||||
7
codex-rs/apply-patch/tests/fixtures/scenarios/023_preserves_crlf_for_update_hunks/patch.txt
vendored
Normal file
7
codex-rs/apply-patch/tests/fixtures/scenarios/023_preserves_crlf_for_update_hunks/patch.txt
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
*** Begin Patch
|
||||
*** Update File: sample.txt
|
||||
@@
|
||||
-one
|
||||
+uno
|
||||
two
|
||||
*** End Patch
|
||||
@@ -0,0 +1 @@
|
||||
* -text
|
||||
@@ -0,0 +1,2 @@
|
||||
hello
|
||||
world
|
||||
@@ -0,0 +1,5 @@
|
||||
*** Begin Patch
|
||||
*** Add File: created.txt
|
||||
+hello
|
||||
+world
|
||||
*** End Patch
|
||||
@@ -0,0 +1 @@
|
||||
* -text
|
||||
@@ -0,0 +1,2 @@
|
||||
first
|
||||
third
|
||||
@@ -0,0 +1,3 @@
|
||||
first
|
||||
second
|
||||
third
|
||||
@@ -0,0 +1,7 @@
|
||||
*** Begin Patch
|
||||
*** Update File: lines.txt
|
||||
@@
|
||||
first
|
||||
-second
|
||||
third
|
||||
*** End Patch
|
||||
@@ -0,0 +1 @@
|
||||
* -text
|
||||
@@ -0,0 +1 @@
|
||||
keep
|
||||
@@ -0,0 +1,2 @@
|
||||
new
|
||||
line
|
||||
@@ -0,0 +1,2 @@
|
||||
old
|
||||
line
|
||||
@@ -0,0 +1 @@
|
||||
keep
|
||||
@@ -0,0 +1,8 @@
|
||||
*** Begin Patch
|
||||
*** Update File: old/name.txt
|
||||
*** Move to: renamed/dir/name.txt
|
||||
@@
|
||||
-old
|
||||
+new
|
||||
line
|
||||
*** End Patch
|
||||
@@ -0,0 +1 @@
|
||||
* -text
|
||||
@@ -0,0 +1,4 @@
|
||||
one
|
||||
dos
|
||||
three
|
||||
cuatro
|
||||
@@ -0,0 +1,4 @@
|
||||
one
|
||||
two
|
||||
three
|
||||
four
|
||||
@@ -0,0 +1,9 @@
|
||||
*** Begin Patch
|
||||
*** Update File: multi.txt
|
||||
@@
|
||||
-two
|
||||
+dos
|
||||
@@
|
||||
-four
|
||||
+cuatro
|
||||
*** End Patch
|
||||
@@ -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(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user