Added Timeout() for Describe and Top Level #95
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What was the previous behavior
Previously, calling
G.Timeout()
inside a Describe or in the top level test function resulted in the following error:panic: runtime error: invalid memory address or nil pointer dereference [recovered]
This was because of this piece of code:
Which behavior is this PR bringing
g.Timeout()
)g.Timeout()
can be called multiple times in which case the given value applies until a newg.Timeout()
is encountered in the same or an higher scope.What would have been another valid behavior ?
It could be coherent that calling
g.Timeout
inside a Describe sets a maximum execution time for the whole Describe, and not for every It inside it. The same way, setting the timeout in the top level function could set a global time for all of the Describes instead of a time per It.Which improvements could be made ?
The test suite for the timeouts is pretty bad, as it calls
time.Sleep()
many times, which makes the testing slow, and it could be interesting to think of a way to mock theSleep
calls.