-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix incorrect use of loop variable (#16872)
This fixes a couple of references to loop variables in parallel tests and deferred functions. When running a parallel test (calling `t.Parallel()`) combined with the table-driven pattern, it's necessary to copy the test case loop variable, otherwise only the last test case is exercised. This is documented in the `testing` package: https://pkg.go.dev/testing#hdr-Subtests_and_Sub_benchmarks `defer` statements that invoke a closure should also not reference a loop variable directly as the referenced value will change in each iteration of the loop. Issues were automatically found with the `loopvarcapture` linter.
- Loading branch information
1 parent
61707d5
commit eb338de
Showing
5 changed files
with
36 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:improvement | ||
agent: fix incorrectly used loop variables in parallel tests and when finalizing seals | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters