Skip to content

Commit

Permalink
Merge pull request #297 from adamdecaf/find-gotest
Browse files Browse the repository at this point in the history
go/lint: look for gotest instead of "go test"
  • Loading branch information
adamdecaf authored Sep 4, 2024
2 parents cb17b08 + 0edb12b commit eeef8a9
Showing 1 changed file with 11 additions and 4 deletions.
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

0 comments on commit eeef8a9

Please sign in to comment.