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

go/lint: look for gotest instead of "go test" #297

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions go/lint-project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,17 @@ coveredStatements=0
maximumCoverage=0
coveragePath=$(mktemp -d)"/coverage.txt"

# Find "gotest" or "go test"
GOTEST=$(which go)" test"
if which -s gotest > /dev/null;
then
GOTEST=$(which gotest 2>&1 | head -n1)
fi

# Run 'go test'
if [[ "$OS_NAME" == "windows" ]]; then
# Just run short tests on Windows as we don't have Docker support in tests worked out for the database tests
go test $GOTAGS "$gotest_packages" "$GORACE" -short -coverprofile="$coveragePath" -covermode=atomic $GOTEST_FLAGS
$GOTEST $GOTAGS "$gotest_packages" "$GORACE" -short -coverprofile="$coveragePath" -covermode=atomic $GOTEST_FLAGS
fi
# Add some default flags to every 'go test' case
if [[ "$GOTEST_FLAGS" == "" ]]; then
Expand All @@ -413,7 +420,7 @@ if [[ "$GOTEST_FLAGS" == "" ]]; then
fi
if [[ "$OS_NAME" != "windows" ]]; then
if [[ "$COVER_THRESHOLD" == "disabled" ]]; then
go test $GOTAGS "$gotest_packages" "$GORACE" -count 1 $GOTEST_FLAGS
$GOTEST $GOTAGS "$gotest_packages" "$GORACE" -count 1 $GOTEST_FLAGS
else
# Optionally profile each package
if [[ "$PROFILE_GOTEST" == "yes" ]]; then
Expand All @@ -426,7 +433,7 @@ if [[ "$OS_NAME" != "windows" ]]; then
dir="."
fi

go test $GOTAGS "$pkg" "$GORACE" \
$GOTEST $GOTAGS "$pkg" "$GORACE" \
-covermode=atomic \
-coverprofile="$dir"/coverage.txt \
-test.cpuprofile="$dir"/cpu.out \
Expand All @@ -442,7 +449,7 @@ if [[ "$OS_NAME" != "windows" ]]; then
done
else
# Otherwise just run Go tests without profiling
go test $GOTAGS "$gotest_packages" "$GORACE" -coverprofile="$coveragePath" -covermode=atomic -count 1 $GOTEST_FLAGS
$GOTEST $GOTAGS "$gotest_packages" "$GORACE" -coverprofile="$coveragePath" -covermode=atomic -count 1 $GOTEST_FLAGS
fi
fi
fi
Expand Down
Loading