Skip to content
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

fix fail test with cover flag #5117

Merged
merged 1 commit into from
Jan 24, 2025
Merged

Conversation

pfi79
Copy link
Contributor

@pfi79 pfi79 commented Jan 23, 2025

Let me remind you that in go they changed the mechanism of tests with the -cover flag. Because of this we started to crash tests with plugins. A temporary solution was found.

Today our colleagues from go replied that they will not change the cover mechanism. So we can exclude dangerous tests from testing with the cover flag, but run them without the flag.

Below is my suggestion on how to do it on a permanent basis.

@pfi79 pfi79 requested a review from a team as a code owner January 23, 2025 16:47
Comment on lines 174 to 186
go test "${flags[@]}" "${race_flags[@]}" -tags "$GO_TAGS" "${parallel[@]}" -short -timeout=20m -skip=NoCover
fi

local -a no_coverage
while IFS= read -r pkg; do no_coverage+=("$pkg"); done < <(no_coverage_test_packages "$@")
if [ "${#no_coverage[@]}" -ne 0 ]; then
echo "test with no coverage"
unset flags[0]
flags=("${flags[@]}")
go test "${flags[@]}" "${race_flags[@]}" -tags "$GO_TAGS" "${no_coverage[@]}" -short -timeout=20m -run=NoCover
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with the approach here, but I was initially confused because I didn't see a -cover flag. Then I realized it was set in line 150 and then unset in line 181.

To make it less confusing, I'd suggest we should not hide the -cover flag inside a flags variable, only to unset it later. Could we just use -cover in the go test statements above to make it more explicit about where -cover is used and where it is not used?

Also I suspect in the future we will forget about why this was done and how it all works together, could you add some comments in the script explaining the rationale?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I just noticed run_tests_with_coverage() further down in the script, I assume that will be broken, could we exclude the NoCover tests there as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Signed-off-by: Fedor Partanskiy <[email protected]>
@denyeart denyeart merged commit d8bb207 into hyperledger:main Jan 24, 2025
15 checks passed
@pfi79 pfi79 deleted the fix-coverage branch January 24, 2025 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants