feat(macos): dynamically detect install root and fix flaky model catalog test#402
Open
huangzhir wants to merge 2 commits into
Open
feat(macos): dynamically detect install root and fix flaky model catalog test#402huangzhir wants to merge 2 commits into
huangzhir wants to merge 2 commits into
Conversation
Owner
|
主要解决了什么呢 |
Owner
|
测试了吗,我这里没有mac |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 Background (修改背景)
macOS 路径自适应检测优化
/Applications目录。然而在实际使用中,许多环境(如受限的开发集群、普通用户环境)不允许或不方便向系统级/Applications目录写入软件。当用户将.app包安装或运行在用户主目录下的~/Applications或其他自定义路径时,程序会因为无法动态感知自身的实际运行位置,而抛出“检测不到自身入口”的错误(无法识别静默启动器与管理工具入口)。/Applications下是否已有已安装的 Codex++ 入口,以保证对系统级安装路径的最大兼容性。std::env::current_exe()溯源当前正在运行的.app包所在的真实母目录(如用户级~/Applications或其他位置)。/Applications。修复 Flaky 单元测试 (model_catalog_uses_active_relay_profile_model_list_for_display)
model_catalog单元测试在部分测试跑测时会出现 Flaky 崩溃。原因是 mock 的RelayProfile中设置的model字段在序列化时被标记了#[serde(skip_serializing)]。在 settings load 阶段反序列化时,由于config_contents属性为空,导致model被清空重置,最终引发断言失败崩溃。config_contents属性,并将relay_mode设置为MixedApi,以契合真实环境的数据还原路径,从根本上解决由于反序列化截断导致的 flaky bug,确保测试 100% 稳定通过。🔍 Key Changes (修改内容与单一职责规范)
为严格遵守单一职责原则 (Single Responsibility Principle),本 PR 仅包含以下两个最核心文件的修改,不包含任何额外的脚本、打包配置或无关的权限变更:
1.
crates/codex-plus-core/src/install/mod.rsdefault_install_root()函数,引入对/Applications和运行环境路径的双重检索和回退机制。2.
crates/codex-plus-core/tests/model_catalog.rsmodel_catalog_uses_active_relay_profile_model_list_for_display中,补充 mockRelayProfile的config_contents和relay_mode属性,确保反序列化模型不丢失。🧪 Verification Results (验证结果)
所有核心功能和模型模块的自动化测试套件在本地均已 100% 成功通过:
cargo test -p codex-plus-core --test installers(6/6 全部 Pass 🟢)cargo test -p codex-plus-core --test model_catalog(6/6 全部 Pass 🟢)cargo test顺利跑通,零编译警告和 Panic。