1#!/usr/bin/env bash
2# Make sure we're not using gos' Testing package any more in integration-cli
3
4export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
5source "${SCRIPTDIR}/.validate"
6
7IFS=$'\n'
8files=( $(validate_diff --diff-filter=ACMR --name-only -- 'integration-cli/*.go' || true) )
9unset IFS
10
11badFiles=()
12for f in "${files[@]}"; do
13	# skip check_test.go since it *does* use the testing package
14	if [ "$f" = "integration-cli/check_test.go" ]; then
15		continue
16	fi
17
18	# we use "git show" here to validate that what's committed doesn't contain golang built-in testing
19	if git show "$VALIDATE_HEAD:$f" | grep -q testing.T; then
20		if [ "$(echo $f | grep '_test')" ]; then
21			# allow testing.T for non- _test files
22			badFiles+=( "$f" )
23		fi
24	fi
25done
26
27if [ ${#badFiles[@]} -eq 0 ]; then
28	echo 'Congratulations!  No testing.T found.'
29else
30	{
31		echo "These files use the wrong testing infrastructure:"
32		for f in "${badFiles[@]}"; do
33			echo " - $f"
34		done
35		echo
36	} >&2
37	false
38fi
39