...
1# This test verifies that issue 56293 has been fixed, and that the
2# insertion of coverage instrumentation doesn't perturb package
3# initialization order.
4
5[short] skip
6
7go test -cover example
8
9-- go.mod --
10module example
11
12go 1.20
13
14-- m.go --
15
16package main
17
18import (
19 "flag"
20)
21
22var (
23 fooFlag = flag.String("foo", "", "this should be ok")
24 foo = flag.Lookup("foo")
25
26 barFlag = flag.String("bar", "", "this should be also ok, but is "+notOK()+".")
27 bar = flag.Lookup("bar")
28)
29
30func notOK() string {
31 return "not OK"
32}
33
34-- m_test.go --
35
36package main
37
38import (
39 "testing"
40)
41
42func TestFoo(t *testing.T) {
43 if foo == nil {
44 t.Fatal()
45 }
46}
47
48func TestBar(t *testing.T) {
49 if bar == nil {
50 t.Fatal()
51 }
52}
View as plain text