From 8bef5e0933e8e6d8b65d605587e42707b0bc9fd3 Mon Sep 17 00:00:00 2001 From: Charles Cunningham Date: Tue, 17 Feb 2026 10:54:56 -0800 Subject: [PATCH] Make compact unit snapshots Bazel-stable --- codex-rs/core/src/compact.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/codex-rs/core/src/compact.rs b/codex-rs/core/src/compact.rs index 4056deb4e2..314f7d78fe 100644 --- a/codex-rs/core/src/compact.rs +++ b/codex-rs/core/src/compact.rs @@ -593,6 +593,15 @@ mod tests { use insta::assert_snapshot; use pretty_assertions::assert_eq; use serde_json::Value; + use std::path::Path; + + fn assert_compact_snapshot(name: &str, rendered: String) { + let mut settings = insta::Settings::clone_current(); + settings.set_snapshot_path(Path::new(env!("CARGO_MANIFEST_DIR")).join("src/snapshots")); + settings.bind(|| { + assert_snapshot!(name, rendered); + }); + } #[test] fn content_items_to_text_joins_non_empty_segments() { @@ -1686,14 +1695,14 @@ keep me updated panic!("expected refreshed history to serialize as array"); }; - assert_snapshot!( + assert_compact_snapshot( "process_compacted_history_reinject_summary_only_shapes", context_snapshot::format_labeled_items_snapshot( "When compaction output contains only a summary user message, canonical context is still reinserted before the summary.", &[("Refreshed History Layout", refreshed_items.as_slice())], &ContextSnapshotOptions::default() .render_mode(ContextSnapshotRenderMode::KindWithTextPrefix { max_chars: 64 }), - ) + ), ); } @@ -1771,14 +1780,14 @@ keep me updated panic!("expected refreshed history to serialize as array"); }; - assert_snapshot!( + assert_compact_snapshot( "process_compacted_history_reinject_above_last_summary_shapes", context_snapshot::format_labeled_items_snapshot( "When compaction output has multiple summary-only user messages and no real user message, canonical context is reinserted above the last summary.", &[("Refreshed History Layout", refreshed_items.as_slice())], &ContextSnapshotOptions::default() .render_mode(ContextSnapshotRenderMode::KindWithTextPrefix { max_chars: 64 }), - ) + ), ); }