Skip to content

Commit 951bb40

Browse files
adonovangopherbot
authored andcommitted
gopls/internal/test/integration/misc: fix flaky test
The random base64 strings in gopls URLs caused occasional spurious matches for the substring t1. This change uses a non-base64 letter to eliminate this source of nondeterminism. Change-Id: I1db1dca8d93cc299b13b591567fa72b2227ac436 Reviewed-on: https://go-review.googlesource.com/c/tools/+/576140 LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Alan Donovan <[email protected]> Reviewed-by: Robert Findley <[email protected]>
1 parent c9b0c65 commit 951bb40

File tree

1 file changed

+30
-29
lines changed

1 file changed

+30
-29
lines changed

gopls/internal/test/integration/misc/webserver_test.go

+30-29
Original file line numberDiff line numberDiff line change
@@ -90,52 +90,53 @@ module example.com
9090
-- a/a.go --
9191
package a
9292
93-
// The '1' suffix is to reduce risk of spurious matches with other HTML substrings.
93+
// The 'π' suffix is to elimimate spurious matches with other HTML substrings,
94+
// in particular the random base64 secret tokens that appear in gopls URLs.
9495
95-
var V1, v1 = 0, 0
96-
const C1, c1 = 0, 0
96+
var Vπ, vπ = 0, 0
97+
const Cπ, cπ = 0, 0
9798
98-
func F1()
99-
func f1()
99+
func ()
100+
func ()
100101
101-
type T1 int
102-
type t1 int
102+
type int
103+
type int
103104
104-
func (T1) M1() {}
105-
func (T1) m1() {}
105+
func (Tπ) Mπ() {}
106+
func (Tπ) mπ() {}
106107
107-
func (t1) M1() {}
108-
func (t1) m1() {}
108+
func (tπ) Mπ() {}
109+
func (tπ) mπ() {}
109110
`
110111
Run(t, files, func(t *testing.T, env *Env) {
111112
uri1 := viewPkgDoc(t, env, "a/a.go")
112113
doc := get(t, uri1)
113114
// (Ideally our code rendering would also
114115
// eliminate unexported symbols...)
115-
checkMatch(t, true, doc, "var V1, v1 = .*0.*0")
116-
checkMatch(t, true, doc, "const C1, c1 = .*0.*0")
116+
checkMatch(t, true, doc, "var Vπ, vπ = .*0.*0")
117+
checkMatch(t, true, doc, "const Cπ, cπ = .*0.*0")
117118

118119
// Unexported funcs/types/... must still be discarded.
119-
checkMatch(t, true, doc, "F1")
120-
checkMatch(t, false, doc, "f1")
121-
checkMatch(t, true, doc, "T1")
122-
checkMatch(t, false, doc, "t1")
120+
checkMatch(t, true, doc, "")
121+
checkMatch(t, false, doc, "")
122+
checkMatch(t, true, doc, "")
123+
checkMatch(t, false, doc, "")
123124

124125
// Also, check that anchors exist (only) for exported symbols.
125126
// exported:
126-
checkMatch(t, true, doc, "<a id='V1'")
127-
checkMatch(t, true, doc, "<a id='C1'")
128-
checkMatch(t, true, doc, "<h3 id='T1'")
129-
checkMatch(t, true, doc, "<h3 id='F1'")
130-
checkMatch(t, true, doc, "<h4 id='T1.M1'")
127+
checkMatch(t, true, doc, "<a id=''")
128+
checkMatch(t, true, doc, "<a id=''")
129+
checkMatch(t, true, doc, "<h3 id=''")
130+
checkMatch(t, true, doc, "<h3 id=''")
131+
checkMatch(t, true, doc, "<h4 id='Tπ.Mπ'")
131132
// unexported:
132-
checkMatch(t, false, doc, "<a id='v1'")
133-
checkMatch(t, false, doc, "<a id='c1'")
134-
checkMatch(t, false, doc, "<h3 id='t1'")
135-
checkMatch(t, false, doc, "<h3 id='f1'")
136-
checkMatch(t, false, doc, "<h4 id='T1.m1'")
137-
checkMatch(t, false, doc, "<h4 id='t1.M1'")
138-
checkMatch(t, false, doc, "<h4 id='t1.m1'")
133+
checkMatch(t, false, doc, "<a id=''")
134+
checkMatch(t, false, doc, "<a id=''")
135+
checkMatch(t, false, doc, "<h3 id=''")
136+
checkMatch(t, false, doc, "<h3 id=''")
137+
checkMatch(t, false, doc, "<h4 id='Tπ.mπ'")
138+
checkMatch(t, false, doc, "<h4 id='tπ.Mπ'")
139+
checkMatch(t, false, doc, "<h4 id='tπ.mπ'")
139140
})
140141
}
141142

0 commit comments

Comments
 (0)