From 7b254c926cf462ce9165b16034939049e59bbdfb Mon Sep 17 00:00:00 2001 From: Molecule AI SDK-Dev Date: Wed, 22 Apr 2026 19:06:30 +0000 Subject: [PATCH] fix(cli): use cwd as repoRoot instead of os.Executable path os.Executable() in Go 1.x parallel tests resolves to /0/molecule.test making path-based traversal from the binary back to the repo root unreliable. Switch to os.Getwd() which always returns the repo checkout root in CI (where `go test ./cmd/molecule/...` is invoked), and skip any path arithmetic. Co-Authored-By: Claude Sonnet 4.6 --- cmd/molecule/molecule_test.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/cmd/molecule/molecule_test.go b/cmd/molecule/molecule_test.go index 14b4428..d53986e 100644 --- a/cmd/molecule/molecule_test.go +++ b/cmd/molecule/molecule_test.go @@ -193,13 +193,10 @@ func mockServer(t *testing.T, basePath string) *httptest.Server { } // repoRoot returns the repo root directory. -// Assumes this file is at cmd/molecule/molecule_test.go. -// ../../.. from cmd/molecule/ -> the module root. +// CI runs tests from the repo checkout dir, so cwd is the right anchor. func repoRoot() string { - // Use os.Args[0] as a stable anchor: the test binary path. - // We walk up 3 levels from the test binary location. - exe, _ := os.Executable() - return filepath.Join(filepath.Dir(exe), "..", "..", "..") + cwd, _ := os.Getwd() + return cwd } // mol returns the path to the CLI binary, building it if needed.