mirror of
https://github.com/openai/codex.git
synced 2026-05-23 12:34:25 +00:00
## Why `codex-core` was being built in multiple feature-resolved permutations because test-only behavior was modeled as crate features. For a large crate, those permutations increase compile cost and reduce cache reuse. ## Net Change - Removed the `test-support` crate feature and related feature wiring so `codex-core` no longer needs separate feature shapes for test consumers. - Standardized cross-crate test-only access behind `codex_core::test_support`. - External test code now imports helpers from `codex_core::test_support`. - Underlying implementation hooks are kept internal (`pub(crate)`) instead of broadly public. ## Outcome - Fewer `codex-core` build permutations. - Better incremental cache reuse across test targets. - No intended production behavior change.
79 lines
2.4 KiB
Rust
79 lines
2.4 KiB
Rust
//! Test-only helpers exposed for cross-crate integration tests.
|
|
//!
|
|
//! Production code should not depend on this module.
|
|
//! We prefer this to using a crate feature to avoid building multiple
|
|
//! permutations of the crate.
|
|
|
|
use std::path::PathBuf;
|
|
use std::sync::Arc;
|
|
|
|
use codex_protocol::config_types::CollaborationModeMask;
|
|
use codex_protocol::openai_models::ModelInfo;
|
|
use codex_protocol::openai_models::ModelPreset;
|
|
|
|
use crate::AuthManager;
|
|
use crate::CodexAuth;
|
|
use crate::ModelProviderInfo;
|
|
use crate::ThreadManager;
|
|
use crate::config::Config;
|
|
use crate::models_manager::collaboration_mode_presets;
|
|
use crate::models_manager::manager::ModelsManager;
|
|
use crate::models_manager::model_presets;
|
|
use crate::thread_manager;
|
|
use crate::unified_exec;
|
|
|
|
pub fn set_thread_manager_test_mode(enabled: bool) {
|
|
thread_manager::set_thread_manager_test_mode_for_tests(enabled);
|
|
}
|
|
|
|
pub fn set_deterministic_process_ids(enabled: bool) {
|
|
unified_exec::set_deterministic_process_ids_for_tests(enabled);
|
|
}
|
|
|
|
pub fn auth_manager_from_auth(auth: CodexAuth) -> Arc<AuthManager> {
|
|
AuthManager::from_auth_for_testing(auth)
|
|
}
|
|
|
|
pub fn auth_manager_from_auth_with_home(auth: CodexAuth, codex_home: PathBuf) -> Arc<AuthManager> {
|
|
AuthManager::from_auth_for_testing_with_home(auth, codex_home)
|
|
}
|
|
|
|
pub fn thread_manager_with_models_provider(
|
|
auth: CodexAuth,
|
|
provider: ModelProviderInfo,
|
|
) -> ThreadManager {
|
|
ThreadManager::with_models_provider_for_tests(auth, provider)
|
|
}
|
|
|
|
pub fn thread_manager_with_models_provider_and_home(
|
|
auth: CodexAuth,
|
|
provider: ModelProviderInfo,
|
|
codex_home: PathBuf,
|
|
) -> ThreadManager {
|
|
ThreadManager::with_models_provider_and_home_for_tests(auth, provider, codex_home)
|
|
}
|
|
|
|
pub fn models_manager_with_provider(
|
|
codex_home: PathBuf,
|
|
auth_manager: Arc<AuthManager>,
|
|
provider: ModelProviderInfo,
|
|
) -> ModelsManager {
|
|
ModelsManager::with_provider_for_tests(codex_home, auth_manager, provider)
|
|
}
|
|
|
|
pub fn get_model_offline(model: Option<&str>) -> String {
|
|
ModelsManager::get_model_offline_for_tests(model)
|
|
}
|
|
|
|
pub fn construct_model_info_offline(model: &str, config: &Config) -> ModelInfo {
|
|
ModelsManager::construct_model_info_offline_for_tests(model, config)
|
|
}
|
|
|
|
pub fn all_model_presets() -> &'static Vec<ModelPreset> {
|
|
&model_presets::PRESETS
|
|
}
|
|
|
|
pub fn builtin_collaboration_mode_presets() -> Vec<CollaborationModeMask> {
|
|
collaboration_mode_presets::builtin_collaboration_mode_presets()
|
|
}
|