[codex] Make AbsolutePathBuf joins infallible (#16981)

Having to check for errors every time join is called is painful and
unnecessary.
This commit is contained in:
pakrym-oai
2026-04-07 10:52:08 -07:00
committed by GitHub
parent 0b9e42f6f7
commit f1a2b920f9
40 changed files with 361 additions and 315 deletions

View File

@@ -31,10 +31,8 @@ async fn agents_instructions(mut builder: TestCodexBuilder) -> Result<String> {
async fn agents_override_is_preferred_over_agents_md() -> Result<()> {
let instructions =
agents_instructions(test_codex().with_workspace_setup(|cwd, fs| async move {
let agents_md = cwd.join("AGENTS.md").expect("absolute AGENTS.md path");
let override_md = cwd
.join("AGENTS.override.md")
.expect("absolute AGENTS.override.md path");
let agents_md = cwd.join("AGENTS.md");
let override_md = cwd.join("AGENTS.override.md");
fs.write_file(&agents_md, b"base doc".to_vec()).await?;
fs.write_file(&override_md, b"override doc".to_vec())
.await?;
@@ -62,8 +60,8 @@ async fn configured_fallback_is_used_when_agents_candidate_is_directory() -> Res
config.project_doc_fallback_filenames = vec!["WORKFLOW.md".to_string()];
})
.with_workspace_setup(|cwd, fs| async move {
let agents_dir = cwd.join("AGENTS.md").expect("absolute AGENTS.md path");
let fallback = cwd.join("WORKFLOW.md").expect("absolute WORKFLOW.md path");
let agents_dir = cwd.join("AGENTS.md");
let fallback = cwd.join("WORKFLOW.md");
fs.create_directory(&agents_dir, CreateDirectoryOptions { recursive: true })
.await?;
fs.write_file(&fallback, b"fallback doc".to_vec()).await?;
@@ -85,10 +83,7 @@ async fn agents_docs_are_concatenated_from_project_root_to_cwd() -> Result<()> {
let instructions = agents_instructions(
test_codex()
.with_config(|config| {
config.cwd = config
.cwd
.join("nested/workspace")
.expect("absolute nested workspace path");
config.cwd = config.cwd.join("nested/workspace");
})
.with_workspace_setup(|cwd, fs| async move {
let nested = cwd.clone();
@@ -96,13 +91,9 @@ async fn agents_docs_are_concatenated_from_project_root_to_cwd() -> Result<()> {
.parent()
.and_then(|parent| parent.parent())
.expect("nested workspace should have a project root ancestor");
let root_agents = root
.join("AGENTS.md")
.expect("absolute root AGENTS.md path");
let git_marker = root.join(".git").expect("absolute .git path");
let nested_agents = nested
.join("AGENTS.md")
.expect("absolute nested AGENTS.md path");
let root_agents = root.join("AGENTS.md");
let git_marker = root.join(".git");
let nested_agents = nested.join("AGENTS.md");
fs.create_directory(&nested, CreateDirectoryOptions { recursive: true })
.await?;