-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fixed suite TearDown ordering #799
Conversation
(cherry picked from commit 92c097a5af7b4bbbe3a66c2e7484f68194cd555a)
@georgelesica-wf could we merge this. |
CI is broken right now and I haven't had time to fix it. It's not running our checks, just the tests. If someone can figure out how to get the code gen to run and can finish making this PR pass then we can start merging again. Until then I'd rather hold off. |
@boyan-soubachov Could you help reviewing this and merge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the contribution, just some questions.
Looking at the Run()
function in suite.go
, it looks quite unwieldy with a high cognitive complexity. Would refactoring make some sense there? Is there a quick, feasible refactor we can do there?
suite/suite_order_test.go
Outdated
@@ -0,0 +1,47 @@ | |||
package suite |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is your logic for putting this in a separate file? Does it not make sense to just have this as another test in suite_test.go
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other file is huge now, thought could separate the tests based on what we test sortof integration vs small function unit tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I do agree that it's becoming a bit large but I don't think navigating it is still a huge problem.
I'd be happy to discuss any ideas you might have about improving its readability & maintainability, whether it involves splitting it up or some other way.
suite/suite.go
Outdated
@@ -111,6 +114,9 @@ func Run(t *testing.T, suite TestingSuite) { | |||
test := testing.InternalTest{ | |||
Name: method.Name, | |||
F: func(t *testing.T) { | |||
defer func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not just defer testSync.Done()
instead of wrapping it in an anonymous function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had some logic which i've removed later. good catch, have updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. Thank you for your contribution! 👍 😄
Using WaitGroup to synchronise between tests so TearDown runs at end.
Having
suite.T().Parallel()
inTestA
causes it to hang. goroutine wait in<-t.signal
at testing.go and suite.go Run to wait ontestsSync
:108
Closes #466