Skip to content

Commit 0aeb6ec

Browse files
CSResselclaude
andauthored
fix(ci): Resolve macOS test failures on GitHub runners (#81)
The mock_acp_agent path resolution only went up one parent directory, which resolved to target/{arch}/{profile}/deps/mock_acp_agent instead of target/{arch}/{profile}/mock_acp_agent where the binary is actually placed. Changed to use .parent().and_then(|p| p.parent()) to correctly navigate from deps/ to the profile directory, matching the pattern used by codex_binary_path() in tui-pty-e2e. --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 725bf66 commit 0aeb6ec

2 files changed

Lines changed: 42 additions & 18 deletions

File tree

.github/workflows/rust-ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,16 @@ jobs:
8282
- name: cargo clippy
8383
run: cargo clippy --target ${{ matrix.target }} --all-features -- -D warnings
8484

85+
# Build mock-acp-agent to a known location for E2E tests
86+
- name: Build mock-acp-agent
87+
run: |
88+
mkdir -p target/mock-acp-out
89+
cargo +nightly build -p mock-acp-agent --profile ci-test --target ${{ matrix.target }} --artifact-dir target/mock-acp-out -Z unstable-options
90+
8591
- name: cargo test
8692
# continue-on-error: true # TODO: Fix pre-existing test failures in codex-app-server
93+
env:
94+
MOCK_ACP_AGENT_BIN: ${{ github.workspace }}/codex-rs/target/mock-acp-out/mock_acp_agent
8795
run: cargo test --profile ci-test --target ${{ matrix.target }} --all-features
8896

8997
# Save cargo home cache

codex-rs/acp/src/registry.rs

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,40 @@ pub fn get_agent_config(model_name: &str) -> Result<AcpAgentConfig> {
6565

6666
match normalized.as_str() {
6767
"mock-model" => {
68-
// Use full path to mock_acp_agent binary from target directory
69-
// This handles both debug and release builds
70-
let exe_path = match std::env::current_exe() {
71-
Ok(p) => {
72-
let mock_path = p
73-
.parent()
74-
.map(|parent| parent.join("mock_acp_agent"))
75-
.unwrap_or_else(|| std::path::PathBuf::from("mock_acp_agent"));
76-
tracing::debug!("Mock ACP agent path resolved to: {}", mock_path.display());
77-
mock_path
78-
}
79-
Err(e) => {
80-
tracing::warn!(
81-
"Failed to get current_exe for mock-model: {}, falling back to 'mock_acp_agent'",
82-
e
83-
);
84-
std::path::PathBuf::from("mock_acp_agent")
85-
}
68+
// Resolve path to mock_acp_agent binary.
69+
//
70+
// Priority:
71+
// 1. MOCK_ACP_AGENT_BIN environment variable (set by CI)
72+
// 2. Relative to current executable (for local development)
73+
let exe_path = if let Ok(env_path) = std::env::var("MOCK_ACP_AGENT_BIN") {
74+
tracing::debug!("Mock ACP agent path from MOCK_ACP_AGENT_BIN: {}", env_path);
75+
std::path::PathBuf::from(env_path)
76+
} else {
77+
// Fall back to resolving relative to current executable.
78+
// This handles both:
79+
// - Running as `codex` binary: target/{profile}/codex -> target/{profile}/
80+
// - Running as test binary: target/{profile}/deps/test -> target/{profile}/
81+
let mock_path = std::env::current_exe()
82+
.ok()
83+
.and_then(|p| {
84+
p.parent().map(|parent| {
85+
// Check if we're in a "deps" directory (test binary context)
86+
let in_deps_dir = parent
87+
.file_name()
88+
.map(|name| name == "deps")
89+
.unwrap_or(false);
90+
91+
if in_deps_dir {
92+
parent.parent().map(|p| p.join("mock_acp_agent"))
93+
} else {
94+
Some(parent.join("mock_acp_agent"))
95+
}
96+
})
97+
})
98+
.flatten()
99+
.unwrap_or_else(|| std::path::PathBuf::from("mock_acp_agent"));
100+
tracing::debug!("Mock ACP agent path resolved to: {}", mock_path.display());
101+
mock_path
86102
};
87103

88104
Ok(AcpAgentConfig {

0 commit comments

Comments
 (0)