Join GitHub today
GitHub is home to over 28 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.