Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SpecContext to ReportAfterSuite callback body. #1345

Merged

Conversation

eugenenosenko
Copy link
Contributor

No description provided.

@onsi
Copy link
Owner

onsi commented Jan 29, 2024

hey sorry for the delay - will take a look at this and share feedback.

@onsi
Copy link
Owner

onsi commented Jan 29, 2024

hey - this is good but I'd like to add a test that exercises passing the context into ReportAfterSuite. Would you be up for adding a test to https://github.com/onsi/ginkgo/blob/master/internal/internal_integration/report_suite_test.go - it doens't have to be super-exhaustive but at least one test that covers:

  • passing a SpecContext to ReportAfterSuite
  • correct behavior when a timeout occurs (i.e. a timeout failure, a configurable timeout, etc.)

this should be additive - I want to keep coverage of the non-context variant a well.

Let me know if you're up for that - the internal integration tests can take a bit to wrap your head around but you should be able to copy and paste and pattern-match your way to victory.

@eugenenosenko
Copy link
Contributor Author

sure

@eugenenosenko
Copy link
Contributor Author

@onsi sorry was a bit busy 😄 updated the PR and also docs

@onsi
Copy link
Owner

onsi commented Feb 24, 2024

thjanks! one last thing - rather than add ReportAfterSuiteContext I'd prefer to simply change ReportAfterSuite to accept any body (or to use generics to accept one of the two allowed types. Are you up for that change? If not I can do it after I merge this in.

@eugenenosenko
Copy link
Contributor Author

@onsi Yeah I was squimish about adding XyzContext api since it didn't fit with existing functions and initially I wanted to have a generic param i.e. :

// could be reused for other functions that do reporting
type ReporterBody interface {
	func(Report) | func(SpecContext, Report)
}

func ReportAfterSuite[B ReporterBody](text string, body B, args ...interface{}) bool {
	combinedArgs := []interface{}{body}
	combinedArgs = append(combinedArgs, args...)
	return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeReportAfterSuite, text, combinedArgs...))
}

but this caused another issue here since generic function has to be instantiated

so DSL code would have to have twe aliased functions:

var ReportAfterSuite2 = ginkgo.ReportAfterSuite[func(ginkgo.SpecContext, ginkgo.Report)]
var ReportAfterSuite = ginkgo.ReportAfterSuite[func(ginkgo.Report)]

which might be valid approach but also could introduce some confusion ( but let me know your opinion )

or alternatively to use any as you've mentioned but that would in turn reduce clarity of the existing API. I'm fine with making those changes but let me know what is your preferred approach

@onsi
Copy link
Owner

onsi commented Feb 24, 2024

hey @eugenenosenko - thanks for giving the generics approach a try. let’s go with any. It’s how much of Ginkgo operates anyway so it’s in keeping with the established pattern.

Thanks for working on this! I appreciate the contribution :)

@eugenenosenko eugenenosenko force-pushed the feature/add-context-to-report-after-suite branch from 1842b21 to 077c727 Compare February 25, 2024 05:46
@eugenenosenko
Copy link
Contributor Author

@onsi my pleasure 😄 I've updated the PR and I think that with little effort similar changes can be made to the ReportBeforeSuite and after reporting hooks

@onsi
Copy link
Owner

onsi commented Feb 25, 2024

wonderful! this looks great, thank you :) if you're up for it since you've done all this work already converting the other nodes would be great (either in this PR or a subsequent one would be fine by me).

thanks so much!

@eugenenosenko
Copy link
Contributor Author

updated the code to include changes to other reporting nodes 😄

@eugenenosenko
Copy link
Contributor Author

@onsi are you ok with the proposed changes? 😄

@onsi
Copy link
Owner

onsi commented Feb 27, 2024

hey @eugenenosenko yes - thanks for the nudge. i was waiting for CI to run and then totally forgot to check back! this all looks good to me. i’ll pull it in and cut a release soon.

@onsi onsi merged commit 881efde into onsi:master Feb 27, 2024
6 checks passed
@eugenenosenko eugenenosenko deleted the feature/add-context-to-report-after-suite branch February 27, 2024 14:45
@eugenenosenko
Copy link
Contributor Author

@onsi great, if you have any other improvement tasks let me know, we use ginkgo extensively so I'll be glad to contribute

@onsi
Copy link
Owner

onsi commented Mar 4, 2024

thanks @eugenenosenko ! this just shipped in v2.16.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants