-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix quickfix list when test duration exceeds timeout
Do not treat a panic caused by a test timeout as an error that occurred within a test's callstack. When go test panics due to a test timeout, the running goroutine's stacktrace only contains entries for the standard library, and there is one goroutine whose stacktrace contains entries for the standard library and the test binary. None of the other goroutines should be considered to contain an error, either, because the panic was not due to any code executing within those goroutines' stacks. Therefore, treat panics caused by a test timeout as an error without a file location.
- Loading branch information
Showing
3 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
autoload/go/test-fixtures/test/src/timeout/timeout_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Run a few parallel tests, all in parallel, using multiple techniques for | ||
// causing the test to take a while so that the stacktraces resulting from a | ||
// test timeout will contain several goroutines to avoid giving a false sense | ||
// of confidence or creating error formats that don't account for the more | ||
// complex scenarios that can occur with timeouts. | ||
|
||
package main | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
) | ||
|
||
func TestSleep(t *testing.T) { | ||
t.Parallel() | ||
time.Sleep(15 * time.Second) | ||
t.Log("expected panic if run with timeout < 15s") | ||
} | ||
|
||
func TestRunning(t *testing.T) { | ||
t.Parallel() | ||
c := time.After(15 * time.Second) | ||
Loop: | ||
for { | ||
select { | ||
case <-c: | ||
break Loop | ||
default: | ||
} | ||
} | ||
|
||
t.Log("expected panic if run with timeout < 15s") | ||
} | ||
|
||
func TestRunningAlso(t *testing.T) { | ||
t.Parallel() | ||
c := time.After(15 * time.Second) | ||
Loop: | ||
for { | ||
select { | ||
case <-c: | ||
break Loop | ||
default: | ||
} | ||
} | ||
t.Log("expected panic if run with timeout < 15s") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters