-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: add goleak to check goroutine leak in tests (#5010)
## Which problem is this PR solving? - Partially Fixes #5006 ## Description of the changes - added a linter to check implementation of goleak in tests - added go leak in some tests ## How was this change tested? - ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [ ] I have added unit tests for the new functionality - [ ] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `yarn lint` and `yarn test` --------- Signed-off-by: Harshvir Potpose <hpotpose62@gmail.com> Signed-off-by: Yuri Shkuro <github@ysh.us> Co-authored-by: Yuri Shkuro <github@ysh.us> Co-authored-by: Yuri Shkuro <yurishkuro@users.noreply.github.com>
- Loading branch information
1 parent
9f63383
commit 74293cd
Showing
11 changed files
with
75 additions
and
2 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
bad_pkgs=0 | ||
|
||
# shellcheck disable=SC2048 | ||
for dir in $*; do | ||
if [[ -f "${dir}/.nocover" ]]; then | ||
continue | ||
fi | ||
testFiles=$(find "${dir}" -maxdepth 1 -name '*_test.go') | ||
good=0 | ||
for test in ${testFiles}; do | ||
if grep -q "TestMain" "${test}" | grep -q "goleak.VerifyTestMain" "${test}"; then | ||
good=1 | ||
break | ||
fi | ||
done | ||
if ((good == 0)); then | ||
echo "🔴 Error(check-goleak): no goleak check in package ${dir}" | ||
((bad_pkgs+=1)) | ||
fi | ||
done | ||
|
||
if ((bad_pkgs > 0)); then | ||
echo "Error(check-goleak): no goleak check in ${bad_pkgs} package(s)." | ||
echo "See https://github.com/jaegertracing/jaeger/pull/5010/files for example of adding the checks." | ||
echo "In the future this will be a fatal error in the CI." | ||
exit 0 # TODO change to 1 in the future | ||
fi |