1 # Ensure buildinfo is populated on test binaries even if they
2 # are not tests for package main. See issue #33976.
3
4 [short] skip 'invokes go test'
5
6 go mod init foo
7 go get example.com/version@v1.0.0
8
9 go test -v
10 stdout '(devel)'
11 stdout 'example.com/version v1.0.0'
12
13 -- foo_test.go --
14 package foo
15
16 import (
17 "runtime/debug"
18 "testing"
19
20 _ "example.com/version"
21 )
22
23 func TestBuildInfo(t *testing.T) {
24 info, ok := debug.ReadBuildInfo()
25 if !ok {
26 t.Fatal("no debug info")
27 }
28 t.Log(info.Main.Version)
29
30 for _, d := range info.Deps {
31 t.Log(d.Path, d.Version)
32 }
33 }
34
View as plain text