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

Tests should not fail fast #909

Merged
merged 2 commits into from Mar 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion test.sh
Expand Up @@ -3,10 +3,18 @@
set -e
echo "" > coverage.txt

failed=0

for d in $(go list ./... | grep -v vendor); do
go test -race -coverprofile=profile.out -covermode=atomic $d
go test -race -coverprofile=profile.out -covermode=atomic $d && true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

&& true is a trick to let script continue even a command failed with set -e.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It preserves exit codes of commands ($?).

rc=$?
if [ $rc != 0 ]; then
failed=$rc
fi
if [ -f profile.out ]; then
cat profile.out >> coverage.txt
rm profile.out
fi
done

exit ${failed}