...
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
7# Skip if new coverage is turned off.
8[!GOEXPERIMENT:coverageredesign] skip
9
10go test -cover example
11
12-- go.mod --
13module example
14
15go 1.20
16
17-- m.go --
18
19package main
20
21import (
22 "flag"
23)
24
25var (
26 fooFlag = flag.String("foo", "", "this should be ok")
27 foo = flag.Lookup("foo")
28
29 barFlag = flag.String("bar", "", "this should be also ok, but is "+notOK()+".")
30 bar = flag.Lookup("bar")
31)
32
33func notOK() string {
34 return "not OK"
35}
36
37-- m_test.go --
38
39package main
40
41import (
42 "testing"
43)
44
45func TestFoo(t *testing.T) {
46 if foo == nil {
47 t.Fatal()
48 }
49}
50
51func TestBar(t *testing.T) {
52 if bar == nil {
53 t.Fatal()
54 }
55}
View as plain text