-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.help wanted
Milestone
Description
Consider the following test program:
package my_test
import "testing"
func TestLineNumber(t *testing.T) {
log := t.Log
log("test")
}
When run with go test -v, the output is:
=== RUN TestLineNumber
--- PASS: TestLineNumber (0.00s)
my_test.go:6: test
PASS
The line number is wrong - it should be 7, not 6.
The testing package internally uses runtime.Caller(3) to identify the user code calling the testing.T logging function. It appears that the log := t.Log line is implicitly creating a closure, i.e. adding to the depth of the call stack, resulting in an incorrect line number.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.help wanted