suite.sh 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # Test success marker. If END_MARKER file exists, we know that all tests
  2. # finished. If FAIL_SUMMARY_FILE exists we know that some tests failed, this
  3. # file will contain information about failed tests. Build is considered
  4. # successful if tests ended without any of them failing.
  5. END_MARKER="$BUILD_DIR/.tests_finished"
  6. FAIL_SUMMARY_FILE="$BUILD_DIR/.test_errors"
  7. fail() {
  8. local test_name="$1"
  9. local message="$2"
  10. : ${message:=Test $test_name failed}
  11. local full_msg="$test_name :: $message"
  12. echo "${full_msg}" >> "${FAIL_SUMMARY_FILE}"
  13. echo "Failed: $full_msg"
  14. FAILED=1
  15. }
  16. ended_successfully() {
  17. if test -f "${FAIL_SUMMARY_FILE}" ; then
  18. echo 'Test failed, complete summary:'
  19. cat "${FAIL_SUMMARY_FILE}"
  20. if [[ "$GITHUB_ACTIONS" == "true" ]]; then
  21. rm -f "$FAIL_SUMMARY_FILE"
  22. fi
  23. return 1
  24. fi
  25. if ! test -f "${END_MARKER}" ; then
  26. echo 'ended_successfully called before end marker was touched'
  27. return 1
  28. fi
  29. return 0
  30. }
  31. end_tests() {
  32. touch "${END_MARKER}"
  33. ended_successfully
  34. }