-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Allow fix tests to run concurrently #1576
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
Conversation
@@ -27,7 +27,9 @@ func TestFix(t *testing.T) { | |||
if os.Getenv("GL_KEEP_TEMP_FILES") == "1" { | |||
t.Logf("Temp dir for fix test: %s", tmpDir) | |||
} else { | |||
defer os.RemoveAll(tmpDir) | |||
t.Cleanup(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.
t.Cleanup
waits for all tests to run, whereas defer
does not.
872c5ac
to
e2fe6a3
Compare
test/register_cleanup.go
Outdated
@@ -0,0 +1,12 @@ | |||
// +build go1.14 |
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'm not completely sure whether it's worth using build tags just to make this work but it is annoying how long the fix tests to run when doing development, so I think it's worth considering.
I think that supporting the build of the project with an unmaintained version of Go is useless, encourages bad practice, and creates unnecessary complexity. IMHO we can drop the support of go1.13, go1.16 will come soon so I think it's the right moment to drop go1.13. |
We can drop 1.13 support if it will really help us to simplify code. I'd better wait until go1.16 if "hack" for 1.13 can be isolated and not overly complicates implementation. |
Oops, wrong button, sorry |
I don't have a simpler hack than these build tags but I'm open to suggestions. I'm also happy to sit in this until go 1.16 is released in February. |
Build tags are ok. |
@ldez What's your take on this? Ok to merge for now or would you rather sit on this until go1.16 is released? I'm happy to patch it up once go1.16 is out. I could even put up a PR immediately and we could merge it in a few months. |
Let's merge it and cleanup later. I've re-checked and 10-12 lines of version specific code is minor overhead. |
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.
LGTM
@ldez Do you have any concerns about merging this as is or would you rather we wait? As mentioned, I can put up a PR to clean this up immediately, to be merged when we stop supporting go 1.13. |
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.
For me, we can wait, but it's just my opinion.
Ensure cleanup doesn't happen until after all tests are done. Also don't require holding a lock since files are not shared between tests.
32a6393
to
9606ad9
Compare
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.
LGTM
I noticed the "fix" tests were taking a while to run because they don't run concurrently. It would take about 12 seconds before and with this change takes about 4 on my local machine.
This change does two things:
I admittedly don't know what resources the shared file lock is designed to protect, but I suspect (2) is safe. This PR does not set
t.Parallel()
at the top-level ofTestFix()
. It would be nice to do that but again I don't know how that would play with disabling use of the file lock.