From 99e909603467a36050e046b7274627debc47959e Mon Sep 17 00:00:00 2001 From: Kenichi Omichi Date: Fri, 4 Sep 2020 19:13:39 +0000 Subject: [PATCH] Remove unused FailfWithOffset() The function has been unused from outside of e2e framework at all since 30b3472f893d8b3d8aceebcd41f124b81bd2c7a6 which added the function. This removes it for code cleanup. --- test/e2e/framework/log.go | 11 +++-------- test/e2e/framework/log_test.go | 4 ++-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/test/e2e/framework/log.go b/test/e2e/framework/log.go index 3d8ca29e14d..43927b2f0e7 100644 --- a/test/e2e/framework/log.go +++ b/test/e2e/framework/log.go @@ -42,16 +42,11 @@ func Logf(format string, args ...interface{}) { 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{}) { - 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...) - skip := offset + 1 + skip := 2 log("FAIL", "%s\n\nFull Stack Trace\n%s", msg, PrunedStack(skip)) e2eginkgowrapper.Fail(nowStamp()+": "+msg, skip) } diff --git a/test/e2e/framework/log_test.go b/test/e2e/framework/log_test.go index 87700097e86..103c7748b87 100644 --- a/test/e2e/framework/log_test.go +++ b/test/e2e/framework/log_test.go @@ -110,9 +110,9 @@ func TestFailureOutput(t *testing.T) { }, testResult{ 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.", - 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.