From 0280b5f83696bb0e41ae8a8418ee61e12705ce33 Mon Sep 17 00:00:00 2001 From: saladday <1203511142@qq.com> Date: Wed, 23 Sep 2026 13:49:37 +0000 Subject: [PATCH] Serialize directory helper tests that open descriptors The descriptor-count assertion in the directory tests assumes no other test in the same binary opens descriptors concurrently. The root-removal and not_directory tests added for Environment Files now take the same test lock. --- packages/codex-executor/src/bin/directory.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/codex-executor/src/bin/directory.rs b/packages/codex-executor/src/bin/directory.rs index 7ac7a56d2..c5e9fec1e 100644 --- a/packages/codex-executor/src/bin/directory.rs +++ b/packages/codex-executor/src/bin/directory.rs @@ -144,6 +144,14 @@ mod tests { use crate::workspace_path::{anchor, directory}; use std::{fs, io, os::unix::fs::symlink}; + // These tests open descriptors, so they share the lock that keeps the + // descriptor-count assertions in the directory tests deterministic. + fn serialized() -> std::sync::MutexGuard<'static, ()> { + crate::directory::TEST_LOCK + .lock() + .unwrap_or_else(|poisoned| poisoned.into_inner()) + } + fn code(result: io::Result) -> String { match result { Ok(value) => value["error"].as_str().unwrap_or("listed").to_string(), @@ -153,6 +161,7 @@ mod tests { #[test] fn only_the_requested_path_resolution_is_not_a_directory() { + let _guard = serialized(); let workspace = tempfile::tempdir().unwrap(); let outside = tempfile::tempdir().unwrap(); let root = workspace.path().join("workspace"); @@ -204,6 +213,7 @@ mod tests { #[test] fn a_root_removed_after_opening_is_a_missing_workspace() { + let _guard = serialized(); let workspace = tempfile::tempdir().unwrap(); let root = workspace.path().join("workspace"); fs::create_dir_all(root.join("d")).unwrap(); @@ -224,6 +234,7 @@ mod tests { #[test] fn a_root_replaced_after_opening_is_a_missing_workspace() { + let _guard = serialized(); let workspace = tempfile::tempdir().unwrap(); let root = workspace.path().join("workspace"); let moved = workspace.path().join("moved");