Skip to content

x/website: TestAPIVersion test fails when GOROOT is the toolchain module #78593

@hyangah

Description

@hyangah
$ go env -changed
GOTOOLCHAIN='go1.26.1+auto'
$ go version
go version go1.26.1 linux/amd64
--- FAIL: TestAPIVersion (0.00s)
    api_test.go:138: sinceFunc("archive/tar", "func", "", "FileInfoHeader") = ""; want "1.1"
    api_test.go:138: sinceFunc("bufio", "type", "", "Scanner") = ""; want "1.1"
    api_test.go:138: sinceFunc("bufio", "method", "*Reader", "WriteTo") = ""; want "1.1"
    api_test.go:138: sinceFunc("bytes", "func", "", "LastIndexByte") = ""; want "1.5"
    api_test.go:138: sinceFunc("crypto", "type", "", "Decrypter") = ""; want "1.5"
    api_test.go:138: sinceFunc("crypto/rsa", "method", "*PrivateKey", "Decrypt") = ""; want "1.5"
    api_test.go:138: sinceFunc("debug/dwarf", "method", "Class", "GoString") = ""; want "1.5"
    api_test.go:138: sinceFunc("os", "func", "", "IsTimeout") = ""; want "1.10"
    api_test.go:138: sinceFunc("strings", "type", "", "Builder") = ""; want "1.10"
    api_test.go:138: sinceFunc("strings", "method", "*Builder", "WriteString") = ""; want "1.10"
    api_test.go:138: sinceFunc("os", "method", "*File", "ReadDir") = ""; want "1.16"

The test failure is caused by a missing dependency on the Go installation's api directory.

  1. What the test does: TestAPIVersion calls api.Load(os.DirFS(runtime.GOROOT())) to read files matching api/go*.txt (e.g., go1.1.txt , go1.2.txt , etc.) from the Go root directory. These files contain the list of symbols added in each Go version.

  2. Where it searches: In your current environment, runtime.GOROOT() points to:
    GOMODCACHE/pkg/mod/golang.org/toolchain@v0.0.1-go1.26.1.linux-amd64

  3. The problem: This directory is a downloaded toolchain and does not contain the api directory.

The tests run by GCB and prod service with _goroot.zip, so they don't have this issue.
How about we skip this test if the api files aren't exist AND GOLANGORG_FORCE_GOROOT_ZIP isn't set?

Metadata

Metadata

Assignees

Labels

BugReportIssues describing a possible bug in the Go implementation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.website

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions