codex: normalize apply_patch fs cwd

This commit is contained in:
starr-openai
2026-04-03 23:26:47 -07:00
parent 350b24d177
commit ffd36edcf8
2 changed files with 17 additions and 11 deletions

View File

@@ -52,7 +52,7 @@ impl EnvironmentApplyPatchFileSystem {
Self {
file_system,
operation_options: FileSystemOperationOptions {
cwd: AbsolutePathBuf::from_absolute_path(cwd).ok(),
cwd: absolute_path(cwd.as_path()).ok(),
..FileSystemOperationOptions::default()
},
}
@@ -67,7 +67,7 @@ impl EnvironmentApplyPatchFileSystem {
file_system,
operation_options: FileSystemOperationOptions {
sandbox_policy: Some(sandbox_policy),
cwd: AbsolutePathBuf::from_absolute_path(cwd).ok(),
cwd: absolute_path(cwd.as_path()).ok(),
},
}
}

View File

@@ -44,8 +44,13 @@ fn absolute_path_normalizes_existing_symlink_ancestor() {
let path = link_root.join("nested").join("file.txt");
let got = absolute_path(path.as_path()).expect("normalize absolute path");
let expected = AbsolutePathBuf::from_absolute_path(real_root.join("nested/file.txt"))
.expect("expected normalized path");
let expected = AbsolutePathBuf::from_absolute_path(
real_root
.canonicalize()
.expect("canonicalize real root")
.join("nested/file.txt"),
)
.expect("expected normalized path");
assert_eq!(got, expected);
}
@@ -190,7 +195,7 @@ async fn verification_filesystem_uses_default_operation_options() {
.as_slice(),
[FileSystemOperationOptions {
sandbox_policy: None,
cwd: Some(AbsolutePathBuf::from_absolute_path(&cwd).expect("absolute cwd")),
cwd: Some(absolute_path(cwd.as_path()).expect("normalized cwd")),
}]
);
assert_eq!(
@@ -199,7 +204,11 @@ async fn verification_filesystem_uses_default_operation_options() {
.lock()
.expect("raw_reads lock")
.as_slice(),
[PathBuf::from("/tmp/apply-patch-verification.txt")]
[
absolute_path(Path::new("/tmp/apply-patch-verification.txt"))
.expect("normalized path")
.into_path_buf()
]
);
}
@@ -228,7 +237,7 @@ async fn apply_filesystem_uses_sandbox_options() {
.as_slice(),
[FileSystemOperationOptions {
sandbox_policy: Some(sandbox_policy.clone()),
cwd: Some(AbsolutePathBuf::from_absolute_path(&cwd).expect("absolute cwd")),
cwd: Some(absolute_path(cwd.as_path()).expect("normalized cwd")),
}]
);
assert_eq!(
@@ -239,10 +248,7 @@ async fn apply_filesystem_uses_sandbox_options() {
.as_slice(),
[FileSystemOperationOptions {
sandbox_policy: Some(sandbox_policy),
cwd: Some(
AbsolutePathBuf::from_absolute_path(PathBuf::from("/tmp/apply-patch-sandboxed"))
.expect("absolute cwd")
),
cwd: Some(absolute_path(cwd.as_path()).expect("normalized cwd")),
}]
);
}