mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Merge pull request #94542 from oomichi/remove-FailfWithOffset
Remove unused FailfWithOffset()
This commit is contained in:
commit
7029430ae3
@ -42,16 +42,11 @@ func Logf(format string, args ...interface{}) {
|
|||||||
log("INFO", format, args...)
|
log("INFO", format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Failf logs the fail info, including a stack trace.
|
// 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").
|
||||||
func Failf(format string, args ...interface{}) {
|
func Failf(format string, args ...interface{}) {
|
||||||
FailfWithOffset(1, format, args...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// FailfWithOffset calls "Fail" and logs the error with a stack trace that starts at "offset" levels above its caller
|
|
||||||
// (for example, for call chain f -> g -> FailfWithOffset(1, ...) error would be logged for "f").
|
|
||||||
func FailfWithOffset(offset int, format string, args ...interface{}) {
|
|
||||||
msg := fmt.Sprintf(format, args...)
|
msg := fmt.Sprintf(format, args...)
|
||||||
skip := offset + 1
|
skip := 2
|
||||||
log("FAIL", "%s\n\nFull Stack Trace\n%s", msg, PrunedStack(skip))
|
log("FAIL", "%s\n\nFull Stack Trace\n%s", msg, PrunedStack(skip))
|
||||||
e2eginkgowrapper.Fail(nowStamp()+": "+msg, skip)
|
e2eginkgowrapper.Fail(nowStamp()+": "+msg, skip)
|
||||||
}
|
}
|
||||||
|
@ -110,9 +110,9 @@ func TestFailureOutput(t *testing.T) {
|
|||||||
},
|
},
|
||||||
testResult{
|
testResult{
|
||||||
name: "[Top Level] log fails",
|
name: "[Top Level] log fails",
|
||||||
output: "INFO: before\nFAIL: I'm failing.\n\nFull Stack Trace\nk8s.io/kubernetes/test/e2e/framework_test.glob..func1.2.1(...)\n\tlog_test.go:56\nk8s.io/kubernetes/test/e2e/framework_test.glob..func1.2()\n\tlog_test.go:57\nk8s.io/kubernetes/test/e2e/framework_test.runTests()\n\tlog_test.go:47" + commonOutput,
|
output: "INFO: before\nFAIL: I'm failing.\n\nFull Stack Trace\nk8s.io/kubernetes/test/e2e/framework_test.glob..func1.2()\n\tlog_test.go:57\nk8s.io/kubernetes/test/e2e/framework_test.runTests()\n\tlog_test.go:47" + commonOutput,
|
||||||
failure: "I'm failing.",
|
failure: "I'm failing.",
|
||||||
stack: "k8s.io/kubernetes/test/e2e/framework_test.glob..func1.2.1(...)\n\tlog_test.go:56\nk8s.io/kubernetes/test/e2e/framework_test.glob..func1.2()\n\tlog_test.go:57\nk8s.io/kubernetes/test/e2e/framework_test.runTests()\n\tlog_test.go:47\n",
|
stack: "k8s.io/kubernetes/test/e2e/framework_test.glob..func1.2()\n\tlog_test.go:57\nk8s.io/kubernetes/test/e2e/framework_test.runTests()\n\tlog_test.go:47\n",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
// Compare individual fields. Comparing the slices leads to unreadable error output when there is any mismatch.
|
// Compare individual fields. Comparing the slices leads to unreadable error output when there is any mismatch.
|
||||||
|
Loading…
Reference in New Issue
Block a user