diff --git a/cmd/gasm/asmhdr_test.go b/cmd/gasm/asmhdr_test.go index 0bba0ff..5691b89 100644 --- a/cmd/gasm/asmhdr_test.go +++ b/cmd/gasm/asmhdr_test.go @@ -5,6 +5,7 @@ package main import ( "os" + "os/exec" "path/filepath" "strings" "testing" @@ -393,13 +394,20 @@ func TestRunCorpusAuditGOOS(t *testing.T) { } // TestGenerateGoAsmHeaderRuntime pins the generator against the real thing: -// the runtime package, whose header the toolchain's own -asmhdr output was -// sampled from. Skipped in short mode: it type-checks the whole package. +// the runtime package of the ambient toolchain, whose header the toolchain's +// own -asmhdr output was sampled from. Skipped in short mode: it type-checks +// the whole package. The GOROOT comes from the go command itself, so the +// test follows whatever toolchain the host provides. func TestGenerateGoAsmHeaderRuntime(t *testing.T) { if testing.Short() { t.Skip("type-checks the whole runtime package") } - dir, err := generateGoAsmHeader("/usr/local/go/src/runtime", "", "amd64", t.TempDir()) + out, err := exec.Command("go", "env", "GOROOT").Output() + if err != nil { + t.Skipf("no Go toolchain: %v", err) + } + runtimeDir := filepath.Join(strings.TrimSpace(string(out)), "src", "runtime") + dir, err := generateGoAsmHeader(runtimeDir, "", "amd64", t.TempDir()) if err != nil { t.Fatalf("generateGoAsmHeader(runtime): %v", err) }