From bc08633705f87911b82f4d8075c53d5959a17b6c Mon Sep 17 00:00:00 2001 From: Vishal Raj Date: Thu, 6 Jun 2024 16:17:42 +0100 Subject: [PATCH] [systemtest] Get repo root correctly with go workspaces --- systemtest/apmservertest/command.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/systemtest/apmservertest/command.go b/systemtest/apmservertest/command.go index 8e6ebe8a2e8..f5fffb583df 100644 --- a/systemtest/apmservertest/command.go +++ b/systemtest/apmservertest/command.go @@ -199,7 +199,18 @@ func getRepoRoot() (string, error) { if err != nil { return "", err } - repoRoot = filepath.Clean(strings.TrimSpace(string(output))) + // When go workspaces is enabled then go list lists all the module paths in + // the go workspace. This is hack to ensure we take what we required. + // TODO (lahsivjar): Better way to find repo root? + allPaths := strings.Split(strings.TrimSpace(string(output)), "\n") + var targetPath string + for _, path := range allPaths { + if strings.HasSuffix(path, "systemtest/..") { + targetPath = path + break + } + } + repoRoot = filepath.Clean(targetPath) return repoRoot, nil }