Files
mgmt/test/test-gotest.sh
James Shubin f3b99b3940 test, integration: Add an integration test framework
This adds an initial implementation of an integration test framework for
writing more complicated tests. In particular this also makes some small
additions to the mgmt core so that testing is easier.
2018-03-13 06:38:21 -04:00

42 lines
983 B
Bash
Executable File

#!/bin/bash
echo running "$0" "$@"
#ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )" # dir!
ROOT=$(dirname "${BASH_SOURCE}")/..
cd "${ROOT}"
. test/util.sh
failures=''
function run-test()
{
$@ || failures=$( [ -n "$failures" ] && echo "$failures\\n$@" || echo "$@" )
}
base=$(go list .)
if [[ "$@" = *"--integration"* ]]; then
if [[ "$@" = *"--race"* ]]; then
run-test go test -race "${base}/integration/"
else
run-test go test "${base}/integration/"
fi
else
for pkg in `go list -e ./... | grep -v "^${base}/vendor/" | grep -v "^${base}/examples/" | grep -v "^${base}/test/" | grep -v "^${base}/old/" | grep -v "^${base}/tmp/" | grep -v "^${base}/integration"`; do
echo -e "\ttesting: $pkg"
if [[ "$@" = *"--race"* ]]; then
run-test go test -race "$pkg"
else
run-test go test "$pkg"
fi
done
fi
if [[ -n "$failures" ]]; then
echo 'FAIL'
echo 'The following `go test` runs have failed:'
echo -e "$failures"
echo
exit 1
fi
echo 'PASS'