Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
testing: add (*T).Deadline #28135
CL 134395 (
That leaves one use-case unaddressed: as @neild noted in the golang-dev thread and @dsnet noted in #18199 (comment), if a test times out (e.g. because of a deadlock in the package under test), it is often useful to shut it down cleanly and emit useful logs rather than wait for the
@bradfitz suggested that test authors can add their own derived context, but a test in general has no idea how much time it has left: if we want to check the
I propose that we add back the
referenced this issue
Oct 11, 2018
The way I see it, current testing is very simple and I like it that way. Adding a
The last attempt at adding Context was trying to signal "this test is done, all you helpers can go away".
I don't see why we should prefer one over the other. They both seem very indirect. The fact that there were these two very different plausible uses suggests that having plain t.Context will be confusing to people expecting one or the other (or a third equally plausible meaning).
If the goal is to expose timeout information, let's focus on an API that does that well, instead of shoehorning it into context.
changed the title
proposal: testing: add (*T).Context, canceled only on timeout, failure, or skip
Dec 12, 2018
We should prefer the second over the first because
It also fits in really well with the Stdlib's adoption of
In #18368 (comment) you closed the issue because
It isn't a testing specific problem yes, but because of
I guess if #15758 is done, then a testing specific solution doesn't matter.