Skip to content

Commit

Permalink
test: re-enable gofmt tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sgotti committed Oct 7, 2021
1 parent fc23394 commit eb9629d
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions test
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,24 @@ echo "Running tests..."

COVER=${COVER:-"-cover"}

# Use only of specific go version to run gofmt since it'll break when some formatting rules change between versions
GOFMT_VERSION="go1.14"

MAJOR_GOVERSION=$( echo -n $(go version) | grep -o 'go1\.[0-9]*' || true )
if [ "${MAJOR_GOVERSION}" == "${GOFMT_VERSION}" ]; then
echo "Checking gofmt..."
fmtRes=$(gofmt -l $(find . -type f -name '*.go' ! -path './vendor/*' ! -path '*/\.*'))
if [ -n "${fmtRes}" ]; then
echo -e "gofmt checking failed:\n${fmtRes}"
exit 255
fi
## Use this code in case we are testing with multiple go versions that have different gofmt outputs
# # Use only of specific go version to run gofmt since it'll break when some formatting rules change between versions
# GOFMT_VERSION="go1.14"
# MAJOR_GOVERSION=$( echo -n $(go version) | grep -o 'go1\.[0-9]*' || true )
# if [ "${MAJOR_GOVERSION}" == "${GOFMT_VERSION}" ]; then
# echo "Checking gofmt..."
# fmtRes=$(gofmt -l $(find . -type f -name '*.go' ! -path './vendor/*' ! -path '*/\.*'))
# if [ -n "${fmtRes}" ]; then
# echo -e "gofmt checking failed:\n${fmtRes}"
# exit 255
# fi
# fi

echo "Checking gofmt..."
fmtRes=$(gofmt -l $(find . -type f -name '*.go' ! -path './vendor/*' ! -path '*/\.*'))
if [ -n "${fmtRes}" ]; then
echo -e "gofmt checking failed:\n${fmtRes}"
exit 255
fi

echo "Checking govet..."
Expand Down

0 comments on commit eb9629d

Please sign in to comment.