Files
kustomize/pre-commit.sh
Hannes Hörl 3ac8575ed8 Make pre-commit.sh work with the test framework
Eventually we want our framework to work nicely with just `go test`. To
get there we need to
- inject KUBE_ASSETS_DIR
- make the framework work when run multiple times in parallel (port
  collitions, expose bound ports the the subject under test, ...)

We decided to make sure our tests are run in sequence (and not in
parallel to any other thing using etcd, for that matter) by making this
explicit in the `pre-commit.sh` - for now.

As soon as we are there, we can rollback the change to the
`pre-commit.sh` end have the test framework be tested the same as
everything else.

[#153248975]
2017-11-29 15:20:41 +00:00

31 lines
574 B
Bash
Executable File

#!/bin/bash
rc=0
go_dirs() {
go list -f '{{.Dir}}' ./... | tr '\n' '\0'
}
echo "Running go fmt"
go_dirs | xargs -0 gofmt -s -d -l
rc=$((rc || $?))
echo "Running goimports"
diff -u <(echo -n) <(go_dirs | xargs -0 goimports -l)
rc=$((rc || $?))
echo "Running go vet"
go vet -all ./...
rc=$((rc || $?))
echo "Running go test"
go list ./... | grep -vF pkg/framework/test | xargs go test -v
rc=$((rc || $?))
echo "Running test framework tests"
./pkg/framework/test/scripts/download-binaries.sh \
&& ./pkg/framework/test/scripts/run-tests.sh
rc=$((rc || $?))
exit $rc