2017-02-13 14:01:54 -05:00
|
|
|
#!/usr/bin/env bash
|
2015-04-22 14:20:32 -04:00
|
|
|
# Make sure we're not using gos' Testing package any more in integration-cli
|
|
|
|
|
2016-10-12 15:25:49 -04:00
|
|
|
export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
source "${SCRIPTDIR}/.validate"
|
2015-04-22 14:20:32 -04:00
|
|
|
|
|
|
|
IFS=$'\n'
|
|
|
|
files=( $(validate_diff --diff-filter=ACMR --name-only -- 'integration-cli/*.go' || true) )
|
|
|
|
unset IFS
|
|
|
|
|
|
|
|
badFiles=()
|
|
|
|
for f in "${files[@]}"; do
|
|
|
|
# skip check_test.go since it *does* use the testing package
|
|
|
|
if [ "$f" = "integration-cli/check_test.go" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2015-10-10 05:21:04 -04:00
|
|
|
# we use "git show" here to validate that what's committed doesn't contain golang built-in testing
|
2015-04-22 14:20:32 -04:00
|
|
|
if git show "$VALIDATE_HEAD:$f" | grep -q testing.T; then
|
2016-08-31 15:31:06 -04:00
|
|
|
if [ "$(echo $f | grep '_test')" ]; then
|
|
|
|
# allow testing.T for non- _test files
|
|
|
|
badFiles+=( "$f" )
|
|
|
|
fi
|
2015-04-22 14:20:32 -04:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ ${#badFiles[@]} -eq 0 ]; then
|
2016-10-12 15:25:49 -04:00
|
|
|
echo 'Congratulations! No testing.T found.'
|
2015-04-22 14:20:32 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "These files use the wrong testing infrastructure:"
|
|
|
|
for f in "${badFiles[@]}"; do
|
|
|
|
echo " - $f"
|
|
|
|
done
|
|
|
|
echo
|
|
|
|
} >&2
|
|
|
|
false
|
|
|
|
fi
|