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

Fixed suite TearDown ordering #799

Merged
merged 3 commits into from
Jan 16, 2020

Conversation

devdinu
Copy link
Contributor

@devdinu devdinu commented Aug 2, 2019

Using WaitGroup to synchronise between tests so TearDown runs at end.

Having suite.T().Parallel() in TestA causes it to hang. goroutine wait in <-t.signal at testing.go and suite.go Run to wait on testsSync :108

Closes #466

Dinesh Kumar added 2 commits August 2, 2019 18:00
(cherry picked from commit 92c097a5af7b4bbbe3a66c2e7484f68194cd555a)
@georgelesica-wf georgelesica-wf added this to the Next Release milestone Aug 12, 2019
@devdinu
Copy link
Contributor Author

devdinu commented Aug 22, 2019

@georgelesica-wf could we merge this.

@georgelesica-wf
Copy link

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.

@devdinu
Copy link
Contributor Author

devdinu commented Dec 11, 2019

@boyan-soubachov Could you help reviewing this and merge.

Copy link
Collaborator

@boyan-soubachov boyan-soubachov left a 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?

@@ -0,0 +1,47 @@
package suite
Copy link
Collaborator

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?

Copy link
Contributor Author

@devdinu devdinu Jan 16, 2020

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.

Copy link
Collaborator

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() {
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

@boyan-soubachov boyan-soubachov left a 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! 👍 😄

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

Successfully merging this pull request may close these issues.

bug in parallel tests
3 participants