Merge pull request #113390 from pohly/e2e-framework-fix-failure-stack

e2e framework: fix incorrect backtrace in Failf
This commit is contained in:
Kubernetes Prow Robot 2022-10-27 13:20:30 -07:00 committed by GitHub
commit 0d4878e448
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -41,11 +41,11 @@ func Logf(format string, args ...interface{}) {
log("INFO", format, args...)
}
// Failf logs the fail info, including a stack trace starts at 2 levels above its caller
// (for example, for call chain f -> g -> Failf("foo", ...) error would be logged for "f").
// Failf logs the fail info, including a stack trace starts with its direct caller
// (for example, for call chain f -> g -> Failf("foo", ...) error would be logged for "g").
func Failf(format string, args ...interface{}) {
msg := fmt.Sprintf(format, args...)
skip := 2
skip := 1
log("FAIL", "%s\n\nFull Stack Trace\n%s", msg, PrunedStack(skip))
fail(nowStamp()+": "+msg, skip)
panic("unreachable")

View File

@ -154,10 +154,14 @@ k8s.io/kubernetes/test/e2e/framework_test.glob..func1.5()
FAIL: I'm failing.
Full Stack Trace
k8s.io/kubernetes/test/e2e/framework_test.glob..func1.3.1(...)
log_test.go:56
k8s.io/kubernetes/test/e2e/framework_test.glob..func1.3()
log_test.go:57` + commonOutput,
Failure: "I'm failing.",
Stack: `k8s.io/kubernetes/test/e2e/framework_test.glob..func1.3()
Stack: `k8s.io/kubernetes/test/e2e/framework_test.glob..func1.3.1(...)
log_test.go:56
k8s.io/kubernetes/test/e2e/framework_test.glob..func1.3()
log_test.go:57`,
},
output.TestResult{