]> Cypherpunks repositories - gostls13.git/commit
cmd/go/internal/lockedfile: avoid failing tests due to arbitrary timeouts
authorBryan C. Mills <bcmills@google.com>
Tue, 10 Jan 2023 17:59:16 +0000 (12:59 -0500)
committerGopher Robot <gobot@golang.org>
Thu, 19 Jan 2023 20:46:09 +0000 (20:46 +0000)
commit2f8f51724ad2a3509603d53d8a850f9146e4016f
tree31e649ed103e8cf1e39e3249ff303d64cd6f3c86
parent24a9d7bc1834d6a4019a965c759d2282fa029229
cmd/go/internal/lockedfile: avoid failing tests due to arbitrary timeouts

The mustBlock helper returns a function that verifies that the blocked
operation does eventually complete. However, it used an arbitrary
10-second timeout in place of “eventually”.

Since the test is checking a synchronization library, bugs are likely
to manifest as deadlocks. It may be useful to log what operation is in
flight if such a deadlock occurs; however, since we can't bound how
long a “reasonable” operation should take, the log message should only
be informational — it should not cause the test to fail.

While we're here, let's also set a better example by not leaking
time.After timers in the tests..

Fixes #57592.

Change-Id: I4e74e42390679bffac7a286824acb71b08994c17
Reviewed-on: https://go-review.googlesource.com/c/go/+/461000
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
src/cmd/go/internal/lockedfile/lockedfile_test.go