Skip to content

Commit

Permalink
Match Ginkgo signatures for By and Fail
Browse files Browse the repository at this point in the history
This allows the framework to use the Ginkgo functions directly,
avoiding an extra call (which would affect call stacks in callbacks).

Signed-off-by: Stephen Kitt <[email protected]>
  • Loading branch information
skitt authored and tpantelis committed Apr 3, 2024
1 parent 17ce6f7 commit 72fb58b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 2 additions & 6 deletions test/e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,9 @@ func init() {
}

func RunE2ETests(t *testing.T) bool {
framework.SetStatusFunction(func(text string) {
By(text)
})
framework.SetStatusFunction(By)

framework.SetFailFunction(func(text string) {
Fail(text)
})
framework.SetFailFunction(Fail)

framework.SetUserAgentFunction(func() string {
return fmt.Sprintf("%v -- %v", rest.DefaultKubernetesUserAgent(), CurrentSpecReport().FullText())
Expand Down
16 changes: 10 additions & 6 deletions test/e2e/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,16 @@ func AddBeforeSuite(beforeSuite func()) {
}

var (
By func(string)
Fail func(string)
By func(string, ...func())
Fail func(string, ...int)
userAgentFunction func() string
)

func SetStatusFunction(by func(string)) {
func SetStatusFunction(by func(string, ...func())) {
By = by
}

func SetFailFunction(fail func(string)) {
func SetFailFunction(fail func(string, ...int)) {
Fail = fail
}

Expand All @@ -152,10 +152,14 @@ func SetUserAgentFunction(uaf func() string) {
}

func init() {
By = func(str string) {
By = func(str string, callbacks ...func()) {
fmt.Println(str)

for _, callback := range callbacks {
callback()
}
}
Fail = func(str string) {
Fail = func(str string, _ ...int) {
panic("Framework Fail:" + str)
}
userAgentFunction = func() string {
Expand Down

0 comments on commit 72fb58b

Please sign in to comment.