postgresql.port.mk 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # $OpenBSD: postgresql.port.mk,v 1.6 2015/09/24 20:35:31 zhuk Exp $
  2. #
  3. # Helps testing PostgreSQL-based software, no B/L/R-DEPS here.
  4. MODPOSTGRESQL_TEST_CMD ?= \
  5. ${MAKE_PROGRAM} ${ALL_TEST_FLAGS} -f ${MAKE_FILE} ${TEST_TARGET}
  6. MODPOSTGRESQL_TEST_PGHOST ?= ${WRKDIR}
  7. _MODPOSTGRESQL_TEST_PGDATA = ${WRKDIR}/testdb-pg
  8. TEST_DEPENDS += databases/postgresql,-server
  9. TEST_ENV += PGDATA=${_MODPOSTGRESQL_TEST_PGDATA} \
  10. PGHOST=${MODPOSTGRESQL_TEST_PGHOST}
  11. .ifdef MODPOSTGRESQL_TEST_DBNAME
  12. TEST_ENV += PGDATABASE=${MODPOSTGRESQL_TEST_DBNAME}
  13. .endif
  14. MODPOSTGRESQL_TEST_TARGET = \
  15. rm -Rf ${_MODPOSTGRESQL_TEST_PGDATA}; \
  16. export ${ALL_TEST_ENV}; \
  17. ${LOCALBASE}/bin/initdb -D ${_MODPOSTGRESQL_TEST_PGDATA} \
  18. -A trust --locale=C -E UTF8 --nosync; \
  19. ${LOCALBASE}/bin/pg_ctl start -w -D ${_MODPOSTGRESQL_TEST_PGDATA} \
  20. -l ${WRKDIR}/pg-test.log \
  21. -o "-F -h '' -k ${MODPOSTGRESQL_TEST_PGHOST}";
  22. .ifdef MODPOSTGRESQL_TEST_DBNAME
  23. MODPOSTGRESQL_TEST_TARGET += \
  24. ${LOCALBASE}/bin/createdb ${MODPOSTGRESQL_TEST_DBNAME} || \
  25. (${LOCALBASE}/bin/pg_ctl stop -D ${_MODPOSTGRESQL_TEST_PGDATA} \
  26. -m i && exit 1);
  27. .endif
  28. MODPOSTGRESQL_TEST_TARGET += \
  29. set +e; \
  30. cd ${WRKBUILD}; \
  31. ( ${MODPOSTGRESQL_TEST_CMD} ); \
  32. Q=$$?; \
  33. ${LOCALBASE}/bin/pg_ctl stop -D ${_MODPOSTGRESQL_TEST_PGDATA} -m i; \
  34. exit $$Q
  35. .if !target(do-test)
  36. do-test:
  37. ${MODPOSTGRESQL_TEST_TARGET}
  38. .endif