run-tests 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #! /bin/bash
  2. #
  3. # © 2017 Ansgar Burchardt <ansgar@debian.org>
  4. # License: GPL-2+
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. set -e
  19. set -u
  20. # find-postgresql-version: () -> str
  21. # locate postgresql version for which both server and debversion
  22. # extension are installed. exits with error if no version is found.
  23. # returns: version, e.g. "9.6"
  24. find-postgresql-version() {
  25. local status
  26. for v in 11 10 9.6 9.4; do
  27. status=$(dpkg-query \
  28. -f'${db:Status-Status} ' \
  29. -W postgresql-${v} postgresql-${v}-debversion 2>/dev/null || :)
  30. if [ "${status}" = "installed installed " ]; then
  31. echo ${v}
  32. exit 0
  33. fi
  34. done
  35. echo "No PostgreSQL version with server and debversion extension found." >&2
  36. exit 1
  37. }
  38. pgversion=$(find-postgresql-version)
  39. export DAK_INTEGRATION_TEST=1
  40. export DAK_ROOT="$(cd $(dirname "$0")/..; pwd)"
  41. for t in "${DAK_ROOT}/integration-tests/tests/"[0-9]*[^~] \
  42. "${DAK_ROOT}/tests/run-dbtests"; do
  43. echo "=== Running ${t##*/}"
  44. pg_virtualenv -v "${pgversion}" "${t}"
  45. done