Files
codex/codex-rs/prompts/src/review_request_tests.rs
T
Adam Perry @ OpenAIandGitHub ba2b67f9cd [codex] Consolidate shared prompts in codex-prompts (#25151)
## Why

`codex_core` is consistently a bottleneck for incremental builds during
iteration. The simplest fix is to make the crate smaller.

## Summary

`codex-core` owns several reusable prompt renderers and static prompt
assets, which makes the crate harder to split apart.

Rename `codex-review-prompts` to `codex-prompts` and move shared review,
goal, permissions, compaction, realtime, hierarchical AGENTS.md, and
`apply_patch` prompts into it. Move prompt-only tests and update
consumers and `CODEOWNERS`.

## Validation

- `just test -p codex-prompts -p codex-apply-patch`
- `just test -p codex-core prompt_caching`
- Bazel builds for the affected crates
2026-06-01 18:45:07 +00:00

52 lines
2.0 KiB
Rust

use super::*;
use pretty_assertions::assert_eq;
#[test]
fn review_prompt_template_renders_base_branch_backup_variant() {
assert_eq!(
render_review_prompt(&BASE_BRANCH_PROMPT_BACKUP_TEMPLATE, [("branch", "main")]),
"Review the code changes against the base branch 'main'. Start by finding the merge diff between the current branch and main's upstream e.g. (`git merge-base HEAD \"$(git rev-parse --abbrev-ref \"main@{upstream}\")\"`), then run `git diff` against that SHA to see what changes we would merge into the main branch. Provide prioritized, actionable findings."
);
}
#[test]
fn review_prompt_template_renders_base_branch_variant() {
assert_eq!(
render_review_prompt(
&BASE_BRANCH_PROMPT_TEMPLATE,
[("base_branch", "main"), ("merge_base_sha", "abc123")]
),
"Review the code changes against the base branch 'main'. The merge base commit for this comparison is abc123. Run `git diff abc123` to inspect the changes relative to main. Provide prioritized, actionable findings."
);
}
#[test]
fn review_prompt_template_renders_commit_variant() {
assert_eq!(
review_prompt(
&ReviewTarget::Commit {
sha: "deadbeef".to_string(),
title: None,
},
&AbsolutePathBuf::current_dir().expect("cwd"),
)
.expect("commit prompt should render"),
"Review the code changes introduced by commit deadbeef. Provide prioritized, actionable findings."
);
}
#[test]
fn review_prompt_template_renders_commit_variant_with_title() {
assert_eq!(
review_prompt(
&ReviewTarget::Commit {
sha: "deadbeef".to_string(),
title: Some("Fix bug".to_string()),
},
&AbsolutePathBuf::current_dir().expect("cwd"),
)
.expect("commit prompt should render"),
"Review the code changes introduced by commit deadbeef (\"Fix bug\"). Provide prioritized, actionable findings."
);
}