fix(cmd): resolve the runtime header test GOROOT from the go command
Test / test (push) Successful in 2m39s

This commit is contained in:
2026-09-21 22:46:07 +02:00
parent 057c4eb545
commit a3e3010e0f
+11 -3
View File
@@ -5,6 +5,7 @@ package main
import ( import (
"os" "os"
"os/exec"
"path/filepath" "path/filepath"
"strings" "strings"
"testing" "testing"
@@ -393,13 +394,20 @@ func TestRunCorpusAuditGOOS(t *testing.T) {
} }
// TestGenerateGoAsmHeaderRuntime pins the generator against the real thing: // TestGenerateGoAsmHeaderRuntime pins the generator against the real thing:
// the runtime package, whose header the toolchain's own -asmhdr output was // the runtime package of the ambient toolchain, whose header the toolchain's
// sampled from. Skipped in short mode: it type-checks the whole package. // 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) { func TestGenerateGoAsmHeaderRuntime(t *testing.T) {
if testing.Short() { if testing.Short() {
t.Skip("type-checks the whole runtime package") 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 { if err != nil {
t.Fatalf("generateGoAsmHeader(runtime): %v", err) t.Fatalf("generateGoAsmHeader(runtime): %v", err)
} }