-
Notifications
You must be signed in to change notification settings - Fork 868
*: enable paralleltest linter #1798
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
6d43d65 to
f7b1312
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.
Pull request overview
This PR enables the paralleltest linter in the golangci configuration and adds t.Parallel() calls to test functions throughout the codebase to allow tests to run concurrently, improving test execution time.
Key changes:
- Added
paralleltestto the enabled linters list in.golangci.yaml - Added
t.Parallel()calls to top-level test functions and subtests across the entire codebase - Applied parallelization to both standalone test functions and testify/suite-based tests
Reviewed changes
Copilot reviewed 165 out of 165 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| .golangci.yaml | Enabled the paralleltest linter |
| worktree_test.go | Added t.Parallel() to 7 test functions including suite runner and standalone tests |
| worktree_status_test.go | Added t.Parallel() to 1 test function |
| worktree_commit_test.go | Added t.Parallel() to 2 test functions |
| utils/trace/trace_test.go | Added t.Parallel() to 5 test functions that modify global state |
| utils/sync/bytes_test.go | Added t.Parallel() to 1 test function |
| utils/merkletrie/* | Added t.Parallel() to 7 test suite runners |
| utils/ioutil/context_test.go | Added t.Parallel() to 6 test functions |
| utils/ioutil/common_test.go | Added t.Parallel() to 1 test suite runner |
| utils/diff/diff_ext_test.go | Added t.Parallel() to 1 test suite runner |
| utils/convert/*.go | Added t.Parallel() to 4 test functions and their subtests |
| utils/binary/read_test.go | Added t.Parallel() to 1 test suite runner |
| tests/pack/*.go | Added t.Parallel() to 4 test functions |
| submodule_test.go | Added t.Parallel() to 1 test suite runner |
| storage/transactional/*.go | Added t.Parallel() to 7 test suite runners |
| storage/filesystem/*.go | Added t.Parallel() to 5 test suite runners and standalone tests |
| status_test.go | Added t.Parallel() to 1 test function and its subtests |
| repository*.go | Added t.Parallel() to 2 test suite runners and 1 standalone test |
| remote_test.go | Added t.Parallel() to 2 test functions |
| prune_test.go | Added t.Parallel() to 1 test suite runner |
| plumbing/transport/*.go | Added t.Parallel() to 15 test suite runners and standalone tests |
| plumbing/transport/ssh/*.go | Added t.Parallel() to 9 test functions including one that modifies global state |
| plumbing/transport/http/*.go | Added t.Parallel() to 7 test suite runners and standalone tests |
| plumbing/transport/git/*.go | Added t.Parallel() to 2 test suite runners |
| plumbing/transport/file/*.go | Added t.Parallel() to 3 test suite runners |
| plumbing/storer/*.go | Added t.Parallel() to 2 test suite runners |
| plumbing/revlist/*.go | Added t.Parallel() to 1 test suite runner |
| plumbing/reference_test.go | Added t.Parallel() to 1 test suite runner |
| plumbing/protocol/packp/*.go | Added t.Parallel() to 17 test suite runners and standalone tests |
| plumbing/objectid_test.go | Added t.Parallel() to 3 test functions and their subtests |
| plumbing/object_test.go | Added t.Parallel() to 1 test suite runner |
| plumbing/object/*.go | Added t.Parallel() to 15 test suite runners |
| plumbing/memory_test.go | Added t.Parallel() to 1 test suite runner |
| plumbing/hasher_test.go | Added t.Parallel() to 3 test functions and their subtests |
| plumbing/hash_test.go | Added t.Parallel() to 1 test suite runner |
| plumbing/hash/hash_test.go | Added t.Parallel() to 2 test functions and their subtests that modify global state |
| plumbing/format/revfile/*.go | Added t.Parallel() to 2 test functions and their subtests |
| plumbing/format/pktline/*.go | Added t.Parallel() to 7 test suite runners and standalone tests |
| plumbing/format/packfile/*.go | Added t.Parallel() to 10 test suite runners and standalone tests with subtests |
| plumbing/format/objfile/*.go | Added t.Parallel() to 2 test suite runners |
| plumbing/format/index/*.go | Added t.Parallel() to 7 test functions |
| plumbing/format/idxfile/*.go | Added t.Parallel() to 4 test suite runners and standalone tests |
| plumbing/format/gitignore/*.go | Added t.Parallel() to 2 test suite runners |
| plumbing/format/gitattributes/*.go | Added t.Parallel() to 3 test suite runners |
| plumbing/format/diff/*.go | Added t.Parallel() to 1 test suite runner |
| plumbing/format/config/*.go | Added t.Parallel() to 6 test suite runners |
| plumbing/format/commitgraph/*.go | Added t.Parallel() to 2 test suite runners and standalone tests |
| plumbing/filemode/*.go | Added t.Parallel() to 1 test suite runner |
| plumbing/cache/*.go | Added t.Parallel() to 2 test suite runners |
| options_test.go | Added t.Parallel() to 1 test suite runner |
| internal/url/*.go | Added t.Parallel() to 1 test suite runner |
| internal/revision/*.go | Added t.Parallel() to 2 test suite runners |
| config/*.go | Added t.Parallel() to 6 test suite runners and standalone tests |
| common_test.go | Added t.Parallel() to 1 test suite runner |
| blame_test.go | Added t.Parallel() to 1 test suite runner |
| backend/http/http_test.go | Added t.Parallel() to 3 test functions |
Comments suppressed due to low confidence (4)
plumbing/transport/ssh/common_test.go:178
- The
TestIssue70Suitetest modifies the globalDefaultAuthBuildervariable (lines 159-161) and then relies on a defer to restore it. However, since the test is marked to run in parallel (line 158), other tests could be accessingDefaultAuthBuilderconcurrently, leading to data races or unexpected behavior. Tests that modify global state should not run in parallel with other tests that might use that same global state.
utils/trace/trace_test.go:85 - The trace tests modify global state through
SetLoggerandSetTargetfunctions, butSetLogger(line 50-52 of trace.go) directly assigns to the globalloggervariable without synchronization, whileSetTargetuses atomic operations. When tests run in parallel, concurrent calls toSetLoggercould cause data races. The tests should either not run in parallel, or the trace package needs to be refactored to be thread-safe for logger changes.
plumbing/hash/hash_test.go:55 - The
TestRegisterHashtest and its subtests modify the globalalgosmap throughRegisterHashcalls. Even though there's adefer reset()at the parent test level, the subtests run in parallel (line 44) and can interfere with each other by registering different hash implementations concurrently. The global map is not protected by any synchronization mechanism, which could lead to data races when tests run in parallel.
plumbing/hash/hash_test.go:107 - The
TestSha1Collisiontest and its subtests also modify the globalalgosmap throughRegisterHashcalls (line 80). With subtests running in parallel (line 87), concurrent modifications to the global map can cause data races. Thedefer reset()only protects against interference with other top-level tests, not between parallel subtests.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f7b1312 to
193961f
Compare
Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>
193961f to
1789031
Compare
|
I'm surprised that the test workflow didn't result in data race as described in #1766. In my local test, a lot of tests failed due to the race. Is this only happening in my machine? |
|
@ferhatelmas looking across a range of successful executions, it feels like the overall execution time hasn't changed much: The same seems to be the case when looking solely at the time taken for the Test to run: I'm not sure this is because |
pjbgf
left a comment
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.
@ferhatelmas thanks for working on this. 🙇




Related to #1753