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