-
-
Notifications
You must be signed in to change notification settings - Fork 266
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
Tests that include t.Parallel()
causes concurrency issues on Windows test runner
#809
Comments
Here's an instance of a test repo that's created but missing the code to properly close it after the test is complete - this might be contributing to the above described problem: git-bug/cache/repo_cache_test.go Line 223 in 96327c3
|
This test utility function creates three repo without closing them: git-bug/entity/dag/common_test.go Line 106 in 96327c3
|
I've got a very crufty branch I've been using for testing that includes 30-40 tests which include I then refactored the entire test suite to exclusively use I've created #810, to describe a couple (final?) places we could end up with blocking behavior and will tackle those before returning to this issue. |
This looks like a real issue.
I think this one is OK because each time this function is used, That said, looking again at that code, it seems that there is a bunch of case where |
Agreed ... on the branch where I've been testing change, I've refactored the tests so that the repositories are always created in the |
As discussed in #803, including a test that calls
t.Parallel()
and uses a temporary directory causes unpredictable failures on the Windows build server. Rerunning a failed check often succeeds but failures report that many different tests randomly fail. This is a pretty clear sign that there's a concurrency issue. Here's the code that originally caused the problem:Linux and MacOS filesystems have a different behavior than Windows - if you delete a file that's in use, it will remove the directory entry but the inodes won't be deleted until all the related file handles have been closed. Changing the code above to the following makes the tests fail less frequently:
Using
t.TempDir()
to create each test's temporary directory also registers an alternate cleanup function that has a different behavior fromos.RemoveAll()
. This function includes the following ToB comment (see https://github.com/golang/go/blob/8a56c7742d96c8ef8e8dcecaf3d1c0e9f022f708/src/testing/testing.go#L1115):It's possible that universally using
t.TempDir()
withingit-bug
will eliminate this issue. It's going to be a bit hard to be sure since the only way to tell is to run the tests repeatedly on Github. There are only three additional occurrences ofos.TempDir()
in the code as most of the tests rely onCreateGoGitTestRepo
for their test repository instance. I've been trying different scenarios in #804 and will make this change next.The text was updated successfully, but these errors were encountered: