Preparing PostgreSQL / PostGIS specific regress tests
In addition to C-Unit tests, we also need a test that tests the function in the PostgreSQL environment. These tests are kept in svn in the /regress folder.
- Create a .sql file listing key preferably corner cases of your function and name it some variant of your function name e.g myfunc.sql. Examples of these are in the /regress folder e.g. dumppoints.sql
- Run this sql file in a PostGIS enabled db using psql and save the output in myfunc_expected -- e.g.
psql -tXA -h localhost -U postgres -d postgis_reg -f myfunc.sql > myfunc_expected
The make check does some regex replaces, so when you put in your expected, it may fail. Replace your expected with the output generated by the make check.
- Add this .sql script to the Makefile.in in trunk/regress (NOTE: we can do this if you are submitting the patch). Also note that if your function relies on a particular version of GEOS that is not the minimum version for the PostGIS release, you need to wrap it in a conditional of the form:
ifeq ($(shell expr $(POSTGIS_GEOS_VERSION) ">=" 32),1) TESTS += myfunc endif