Skip to content

Commit 88c9e85

Browse files
committed
v0.56.1 — Fix mcpclient tests: build fakeserver from source instead of using pre-compiled binary
The committed fakeserver binary was ELF x86-64 (Linux), causing "exec format error" on macOS ARM64. Fixed by compiling the fake MCP server from testdata/main.go on-the-fly at test time. Changes: - internal/mcpclient/client_test.go: fakeServerPath now runs go build - cmd/odek/mcp_e2e_test.go: fakeMCPPath now runs go build - cmd/odek/subagent_e2e_test.go: fix hardcoded /root/projects/odek paths - Remove pre-compiled binary (5.8 MB) from git - Add fakeserver to .gitignore
1 parent 00ad31d commit 88c9e85

5 files changed

Lines changed: 36 additions & 12 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ odek-bin
66
.plans/
77
.hermes/
88
notify-channel-proposal.md
9+
internal/mcpclient/testdata/fakeserver

cmd/odek/mcp_e2e_test.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ package main
33
import (
44
"context"
55
"os"
6+
"os/exec"
67
"path/filepath"
8+
"runtime"
79
"testing"
810

911
"github.com/BackendStack21/odek/internal/mcpclient"
@@ -15,11 +17,21 @@ import (
1517
// them, and verify the full ToolAdapter round-trip. Gated by ODEK_E2E=true
1618
// since they spawn external processes.
1719

18-
// fakeMCPPath returns the path to the pre-compiled fake MCP server binary.
19-
// The test runs inside cmd/odek/, so we go up two levels to reach the repo root.
20+
// fakeMCPPath compiles the fake MCP server from source on-the-fly
21+
// and returns the path to the compiled binary.
2022
func fakeMCPPath(t *testing.T) string {
2123
t.Helper()
22-
return filepath.Join("..", "..", "internal", "mcpclient", "testdata", "fakeserver")
24+
_, thisFile, _, _ := runtime.Caller(0)
25+
// Navigate from cmd/odek/ to the repo root, then to internal/mcpclient/testdata/
26+
repoRoot := filepath.Join(filepath.Dir(thisFile), "..", "..")
27+
testdataDir := filepath.Join(repoRoot, "internal", "mcpclient", "testdata")
28+
exePath := filepath.Join(t.TempDir(), "fakeserver")
29+
cmd := exec.Command("go", "build", "-o", exePath, testdataDir)
30+
cmd.Dir = repoRoot // run from module root so go.mod is found
31+
if out, err := cmd.CombinedOutput(); err != nil {
32+
t.Fatalf("build fakeserver: %v\n%s", err, out)
33+
}
34+
return exePath
2335
}
2436

2537
func skipIfNoMCPE2E(t *testing.T) {

cmd/odek/subagent_e2e_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"os"
88
"os/exec"
99
"path/filepath"
10+
"runtime"
1011
"strings"
1112
"testing"
1213
"time"
@@ -52,12 +53,16 @@ func TestMain(m *testing.M) {
5253
e2eBinDir = dir
5354
e2eBinary = filepath.Join(dir, ".odek")
5455

56+
// Resolve repo root from this source file
57+
_, thisFile, _, _ := runtime.Caller(0)
58+
repoRoot := filepath.Join(filepath.Dir(thisFile), "..", "..")
59+
5560
cmd := exec.Command("go", "build",
5661
"-ldflags", "-X main.version=v0.0.0-e2e",
5762
"-o", e2eBinary,
58-
"/root/projects/odek/cmd/odek/",
63+
filepath.Join(repoRoot, "cmd", "odek"),
5964
)
60-
cmd.Dir = "/root/projects/odek"
65+
cmd.Dir = repoRoot
6166
stderr := &bytes.Buffer{}
6267
cmd.Stderr = stderr
6368
if err := cmd.Run(); err != nil {

internal/mcpclient/client_test.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,27 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7-
"os"
7+
"os/exec"
88
"path/filepath"
9+
"runtime"
910
"strings"
1011
"testing"
1112
"time"
1213
)
1314

14-
// fakeServerPath returns the path to the pre-compiled fake MCP server.
15+
// fakeServerPath compiles the fake MCP server from source on-the-fly
16+
// and returns the path to the compiled binary. The binary is placed in
17+
// t.TempDir() and cleaned up automatically when the test completes.
1518
func fakeServerPath(t *testing.T) string {
1619
t.Helper()
17-
dir, err := os.Getwd()
18-
if err != nil {
19-
t.Fatalf("Getwd: %v", err)
20-
}
21-
return filepath.Join(dir, "testdata", "fakeserver")
20+
_, thisFile, _, _ := runtime.Caller(0)
21+
testdataDir := filepath.Join(filepath.Dir(thisFile), "testdata")
22+
exePath := filepath.Join(t.TempDir(), "fakeserver")
23+
cmd := exec.Command("go", "build", "-o", exePath, testdataDir)
24+
if out, err := cmd.CombinedOutput(); err != nil {
25+
t.Fatalf("build fakeserver: %v\n%s", err, out)
26+
}
27+
return exePath
2228
}
2329

2430
func TestNew_NonExistentCommand(t *testing.T) {
-2.83 MB
Binary file not shown.

0 commit comments

Comments
 (0)