mirror of
https://github.com/openai/codex.git
synced 2026-09-05 15:18:41 +00:00
test(tui): normalize boxed snapshot paths
This commit is contained in:
@@ -63,6 +63,25 @@ pub(super) fn normalize_snapshot_paths(text: impl Into<String>) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
/// Normalizes platform-specific test paths without collapsing box alignment.
|
||||
pub(super) fn normalize_box_snapshot_paths(text: &str) -> String {
|
||||
text.lines()
|
||||
.map(|rendered| {
|
||||
let normalized = normalize_snapshot_paths(rendered);
|
||||
let padding = rendered
|
||||
.chars()
|
||||
.count()
|
||||
.saturating_sub(normalized.chars().count());
|
||||
if let Some((content, suffix)) = normalized.rsplit_once('│') {
|
||||
format!("{content}{}│{suffix}", " ".repeat(padding))
|
||||
} else {
|
||||
normalized
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n")
|
||||
}
|
||||
|
||||
pub(super) fn normalized_backend_snapshot<T: std::fmt::Display>(value: &T) -> String {
|
||||
let platform_test_cwd = test_path_display("/tmp/project");
|
||||
let rendered = format!("{value}");
|
||||
@@ -79,7 +98,7 @@ pub(super) fn normalized_backend_snapshot<T: std::fmt::Display>(value: &T) -> St
|
||||
.and_then(|line| line.strip_suffix('"'))
|
||||
{
|
||||
let width = content.chars().count();
|
||||
let normalized = normalize_snapshot_paths(content);
|
||||
let normalized = normalize_box_snapshot_paths(content);
|
||||
format!("\"{normalized:width$}\"")
|
||||
} else {
|
||||
normalize_snapshot_paths(line)
|
||||
|
||||
@@ -1649,24 +1649,7 @@ async fn startup_header_handoff_visible_states_snapshot() {
|
||||
if cell.as_any().is::<history_cell::SessionInfoCell>() =>
|
||||
{
|
||||
let rendered = lines_to_single_string(&cell.display_lines(width));
|
||||
let normalized = normalize_snapshot_paths(&rendered);
|
||||
// Keep box alignment after shortening Windows test paths.
|
||||
break normalized
|
||||
.lines()
|
||||
.zip(rendered.lines())
|
||||
.map(|(normalized, rendered)| {
|
||||
let padding = rendered
|
||||
.chars()
|
||||
.count()
|
||||
.saturating_sub(normalized.chars().count());
|
||||
if let Some(content) = normalized.strip_suffix('│') {
|
||||
format!("{content}{}│", " ".repeat(padding))
|
||||
} else {
|
||||
normalized.to_string()
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
break normalize_box_snapshot_paths(&rendered);
|
||||
}
|
||||
Ok(_) => continue,
|
||||
other => panic!("expected queued configured header, got {other:?}"),
|
||||
|
||||
Reference in New Issue
Block a user