Freeze the clock in permission and skill history tests (#65262)

## Why

When a test spans midnight, the environment date can change between turns
and alter the request history.

## What changed

Use a shared fixed clock for the catalog permission-path model-switch
and repository skill grant history tests. The clock keeps the environment
date stable with time reminders disabled.

GitOrigin-RevId: 7c3ad23547cd9126c6115aeeea6806b32c04dd69
This commit is contained in:
jif
2026-12-02 14:09:46 +00:00
committed by copyberry
parent ba4148faaf
commit 1df7f6d42b
3 changed files with 22 additions and 3 deletions
@@ -68,7 +68,23 @@ enum ClockSetup {
RequiredOff,
}
/// Keep the environment date stable across turns without enabling time reminders.
pub(super) fn test_codex_with_fixed_clock() -> core_test_support::test_codex::TestCodexBuilder {
test_codex()
.with_config(|config| {
config.current_time_reminder = Some(CurrentTimeReminderConfig {
clock_source: CurrentTimeSource::External,
..Default::default()
});
})
.with_external_time_provider(Arc::new(TestTimeProvider {
step_seconds: 0,
..Default::default()
}))
}
struct TestTimeProvider {
step_seconds: i64,
current_time: AtomicI64,
sleep_seconds: AtomicU64,
scripted_current_time: Option<Mutex<VecDeque<Result<i64, &'static str>>>>,
@@ -77,6 +93,7 @@ struct TestTimeProvider {
impl Default for TestTimeProvider {
fn default() -> Self {
Self {
step_seconds: 60,
current_time: AtomicI64::new(FIRST_TIME_UNIX_SECONDS),
sleep_seconds: AtomicU64::new(0),
scripted_current_time: None,
@@ -93,7 +110,9 @@ impl TimeProvider for TestTimeProvider {
.pop_front()
.expect("unexpected test clock read")
} else {
Ok(self.current_time.fetch_add(60, Ordering::Relaxed))
Ok(self
.current_time
.fetch_add(self.step_seconds, Ordering::Relaxed))
};
let timestamp = timestamp.map_err(anyhow::Error::msg)?;
@@ -1156,7 +1156,7 @@ pub(super) async fn catalog_permission_paths_model_change_requests(
})
.collect();
let include_denied_reads = matches!(scenario, PermissionPathScenario::DeniedReads);
let mut builder = test_codex()
let mut builder = super::current_time_reminder::test_codex_with_fixed_clock()
.with_model(first_slug)
.with_workspace_setup(move |cwd, fs| async move {
if include_denied_reads {
@@ -1170,7 +1170,7 @@ pub(super) async fn repository_skill_grant_history(
let (extensions, _events) =
catalog_extensions(SkillCatalog::default(), /*include_host_provider*/ true);
let harness = TestCodexHarness::with_auto_env_builder(
test_codex()
super::current_time_reminder::test_codex_with_fixed_clock()
.with_extensions(extensions)
.with_model_info_override("gpt-5.5", |model| {
model.include_skills_usage_instructions = false