From 896c6fa082b1b14a5491c33d769a84f8f78ae358 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Wed, 2 Nov 2022 18:12:30 +0100 Subject: [PATCH] e2e framework: add AnnotatedLocationWithOffset This is useful in helper functions which themselves don't need to be recorded. --- test/e2e/framework/ginkgowrapper.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/e2e/framework/ginkgowrapper.go b/test/e2e/framework/ginkgowrapper.go index aa3d6c0a475..ebeea8acce9 100644 --- a/test/e2e/framework/ginkgowrapper.go +++ b/test/e2e/framework/ginkgowrapper.go @@ -52,7 +52,13 @@ func IgnoreNotFound(in any) any { // locations by passing the result as additional parameter to a // BeforeEach/AfterEach/DeferCleanup/It/etc. func AnnotatedLocation(annotation string) types.CodeLocation { - codeLocation := types.NewCodeLocation(1) + return AnnotatedLocationWithOffset(annotation, 1) +} + +// AnnotatedLocationWithOffset skips additional call stack levels. With 0 as offset +// it is identical to [AnnotatedLocation]. +func AnnotatedLocationWithOffset(annotation string, offset int) types.CodeLocation { + codeLocation := types.NewCodeLocation(offset + 1) codeLocation.FileName = path.Base(codeLocation.FileName) codeLocation = types.NewCustomCodeLocation(annotation + " | " + codeLocation.String()) return codeLocation