go.net/context: adjust TestAlloc so it passes on windows
Do not assume that a particular code path is selected
in WithTimeout.
Also Windows cannot wait for less then 15 millisecond,
so use that instead of 1 nanosecond in test. Otherwise
test takes too long while it looks like it is quick.
Fixes golang/go#8033.
LGTM=crawshaw
R=golang-codereviews, crawshaw
CC=golang-codereviews
https://golang.org/cl/103470044
diff --git a/context/context_test.go b/context/context_test.go
index 7344dbc..2afc1e7 100644
--- a/context/context_test.go
+++ b/context/context_test.go
@@ -310,12 +310,12 @@
gccgoLimit: 3,
},
{
- desc: "WithTimeout(bg, 1*time.Nanosecond)",
+ desc: "WithTimeout(bg, 15*time.Millisecond)",
f: func() {
- c, _ := WithTimeout(bg, 1*time.Nanosecond)
+ c, _ := WithTimeout(bg, 15*time.Millisecond)
<-c.Done()
},
- limit: 7,
+ limit: 9,
gccgoLimit: 13,
},
{
@@ -345,7 +345,7 @@
// TOOD(iant): Remove this when gccgo does do escape analysis.
limit = test.gccgoLimit
}
- if n := testing.AllocsPerRun(1000, test.f); n > limit {
+ if n := testing.AllocsPerRun(100, test.f); n > limit {
t.Errorf("%s allocs = %f want %d", test.desc, n, int(limit))
}
}