2014-03-04 16:50:54 -08:00
|
|
|
#!/bin/bash -e
|
2014-05-10 01:42:57 -07:00
|
|
|
#
|
|
|
|
# Run all coreos-cloudinit tests
|
|
|
|
# ./test
|
|
|
|
# ./test -v
|
|
|
|
#
|
|
|
|
# Run tests for one package
|
|
|
|
# PKG=initialize ./test
|
|
|
|
#
|
2014-03-04 16:50:54 -08:00
|
|
|
|
2014-05-10 01:42:57 -07:00
|
|
|
# Invoke ./cover for HTML output
|
|
|
|
COVER=${COVER:-"-cover"}
|
|
|
|
|
|
|
|
source ./build
|
|
|
|
|
2014-09-21 19:22:13 -07:00
|
|
|
declare -a TESTPKGS=(
|
|
|
|
config
|
2014-10-22 11:27:51 -07:00
|
|
|
config/validate
|
2014-09-21 19:22:13 -07:00
|
|
|
datasource
|
|
|
|
datasource/configdrive
|
|
|
|
datasource/file
|
|
|
|
datasource/metadata
|
|
|
|
datasource/metadata/cloudsigma
|
|
|
|
datasource/metadata/digitalocean
|
|
|
|
datasource/metadata/ec2
|
|
|
|
datasource/proc_cmdline
|
|
|
|
datasource/url
|
2014-10-10 11:27:27 -07:00
|
|
|
datasource/waagent
|
2014-09-21 19:22:13 -07:00
|
|
|
initialize
|
|
|
|
network
|
|
|
|
pkg
|
|
|
|
system
|
|
|
|
)
|
2014-05-10 01:42:57 -07:00
|
|
|
|
|
|
|
if [ -z "$PKG" ]; then
|
2015-01-26 15:01:56 -08:00
|
|
|
GOFMTPATH="${TESTPKGS[*]} *.go"
|
2014-05-10 01:42:57 -07:00
|
|
|
# prepend repo path to each package
|
2014-08-25 12:36:04 -07:00
|
|
|
TESTPKGS="${TESTPKGS[*]/#/${REPO_PATH}/} ./"
|
2014-05-10 01:42:57 -07:00
|
|
|
else
|
|
|
|
GOFMTPATH="$TESTPKGS"
|
|
|
|
# strip out slashes and dots from PKG=./foo/
|
|
|
|
TESTPKGS=${PKG//\//}
|
|
|
|
TESTPKGS=${TESTPKGS//./}
|
|
|
|
TESTPKGS=${TESTPKGS/#/${REPO_PATH}/}
|
|
|
|
fi
|
2014-03-04 16:50:54 -08:00
|
|
|
|
|
|
|
echo "Running tests..."
|
2014-05-10 01:42:57 -07:00
|
|
|
go test -i ${TESTPKGS}
|
|
|
|
go test ${COVER} $@ ${TESTPKGS}
|
|
|
|
|
|
|
|
echo "Checking gofmt..."
|
|
|
|
fmtRes=$(gofmt -l $GOFMTPATH)
|
2014-08-25 12:36:04 -07:00
|
|
|
if [ -n "$fmtRes" ]; then
|
|
|
|
echo "$fmtRes"
|
|
|
|
exit 1
|
|
|
|
fi
|
2014-05-10 01:42:57 -07:00
|
|
|
|
2014-10-23 11:46:40 -07:00
|
|
|
echo "Checking govet..."
|
|
|
|
vetRes=$(go vet $TESTPKGS)
|
|
|
|
if [ -n "${vetRes}" ]; then
|
|
|
|
echo -e "govet checking failed:\n${vetRes}"
|
|
|
|
exit 255
|
|
|
|
fi
|
|
|
|
|
2014-05-10 01:42:57 -07:00
|
|
|
echo "Success"
|