test-boilerplate.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/bash
  2. # Copyright 2020, gRPC Authors All rights reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. set -eu
  16. # The name of the test, i.e. the directory it is contained in.
  17. TEST=$(basename "${HERE}")
  18. # Directory to read .proto files from.
  19. PROTO_DIR="${HERE}/proto"
  20. # Root directory into which generated code should be written.
  21. OUTPUT_DIR="${HERE}/generated"
  22. # Root directory containing the known good generated code.
  23. GOLDEN_DIR="${HERE}/golden"
  24. # Export these so they're available in the test scripts.
  25. export TEST PROTO_DIR OUTPUT_DIR GOLDEN_DIR
  26. function prepare {
  27. rm -rf "${OUTPUT_DIR}"
  28. mkdir "${OUTPUT_DIR}"
  29. }
  30. function validate {
  31. diff "${OUTPUT_DIR}" "${GOLDEN_DIR}"
  32. }