test-imports 991 B

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