github.com/munnerz/test-infra@v0.0.0-20190108210205-ce3d181dc989/gcsweb/build/test.sh (about)

     1  #!/bin/sh
     2  
     3  # Copyright 2016 The Kubernetes Authors.
     4  #
     5  # Licensed under the Apache License, Version 2.0 (the "License");
     6  # you may not use this file except in compliance with the License.
     7  # You may obtain a copy of the License at
     8  #
     9  #     http://www.apache.org/licenses/LICENSE-2.0
    10  #
    11  # Unless required by applicable law or agreed to in writing, software
    12  # distributed under the License is distributed on an "AS IS" BASIS,
    13  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  # See the License for the specific language governing permissions and
    15  # limitations under the License.
    16  
    17  set -o errexit
    18  set -o nounset
    19  set -o pipefail
    20  
    21  export CGO_ENABLED=0
    22  
    23  TARGETS=$(for d in "$@"; do echo ./$d/...; done)
    24  
    25  echo "Running tests:"
    26  go test -i -installsuffix "static" ${TARGETS}
    27  go test -installsuffix "static" ${TARGETS}
    28  echo
    29  
    30  echo -n "Checking gofmt: "
    31  ERRS=$(find "$@" -type f -name \*.go | xargs gofmt -l 2>&1 || true)
    32  if [ -n "${ERRS}" ]; then
    33      echo "FAIL - the following files need to be gofmt'ed:"
    34      for e in ${ERRS}; do
    35          echo "    $e"
    36      done
    37      echo
    38      exit 1
    39  fi
    40  echo "PASS"
    41  echo
    42  
    43  echo -n "Checking go vet: "
    44  ERRS=$(go vet ${TARGETS} 2>&1 || true)
    45  if [ -n "${ERRS}" ]; then
    46      echo "FAIL"
    47      echo "${ERRS}"
    48      echo
    49      exit 1
    50  fi
    51  echo "PASS"
    52  echo