fix(cmd): locate GOROOT when the build is trimmed

Assisted-by: GLM 5.3 Flash
This commit is contained in:
petrbalvin committed 2026-10-06 20:24:39 +02:00
1 parent ae1baa0e61
commit 0768b4dc84
2 files changed
+43

No files matched your search

+18
View File
@@ -285,6 +285,24 @@ func TestGoAsmHeaderResolved(t *testing.T) {
}
}
// TestResolveGOROOT holds the two resolutions the header generator leans
// on: a baked root that is a real directory passes through, and a missing
// one falls back to what go env GOROOT names, which is what a -trimpath
// build needs.
func TestResolveGOROOT(t *testing.T) {
out, err := exec.Command("go", "env", "GOROOT").Output()
if err != nil {
t.Skip("go env GOROOT unavailable:", err)
}
root := strings.TrimSpace(string(out))
if got := resolveGOROOT(root); got != root {
t.Fatalf("a real baked root must pass through, got %q", got)
}
if got := resolveGOROOT(filepath.Join(root, "nonexistent")); got != root {
t.Fatalf("a missing baked root must resolve to %q, got %q", root, got)
}
}
func TestOtherGOOSFile(t *testing.T) {
for path, want := range map[string]bool{
"/x/sys_windows_amd64.s": true,