#!/bin/bash

set -e

SCRIPT_DIR=`dirname $0`
cd ${SCRIPT_DIR}/..

echo "Go formatting..."
go fmt $(go list ./...)

echo "Go vetting..."
go vet $(go list ./...)

echo "Recursive ginkgo... ${*:+(with parameter(s) }$*${*:+)}"
ginkgo -r --race --randomize-all --fail-on-pending -cover $*

if [ -z "$KEEP_COVER" -o -z "$CI" ]; then
  echo "Not in CI, deleting coverprofile"
  find . -name *.coverprofile -delete
fi
