diff --git a/TODO.md b/TODO.md index a60dbc7..11b9c2a 100644 --- a/TODO.md +++ b/TODO.md @@ -1,6 +1,6 @@ ### Complete the structure: -* Support versioning +* [x] Support versioning * Test use of `pgpy` from python Package * Add integration tests * Add `pysal` dependency and wrapper diff --git a/pg/Makefile b/pg/Makefile index acc6bf3..858da71 100644 --- a/pg/Makefile +++ b/pg/Makefile @@ -1,20 +1,36 @@ +# Makefile to generate the extension out of separate sql source files. +# Once a version is released, it is not meant to be changed. E.g: once version 0.0.1 is out, it SHALL NOT be changed. + EXTENSION = crankshaft EXTVERSION = $(shell grep default_version $(EXTENSION).control | sed -e "s/default_version[[:space:]]*=[[:space:]]*'\([^']*\)'/\1/") -DATA = dist/$(EXTENSION)--$(EXTVERSION).sql +# The new version to be generated from templates +NEW_EXTENSION_ARTIFACT = dist/$(EXTENSION)--$(EXTVERSION).sql -SOURCES_DATA_DIR = sql +# DATA is a special variable used by postgres build infrastructure +# These are the files to be installed in the server shared dir, +# for installation from scratch, upgrades and downgrades. +# @see http://www.postgresql.org/docs/current/static/extend-pgxs.html +DATA = $(NEW_EXTENSION_ARTIFACT) + +SOURCES_DATA_DIR = sql/$(EXTVERSION) SOURCES_DATA = $(wildcard sql/$(EXTVERSION)/*.sql) -dist/$(EXTENSION)--$(EXTVERSION).sql: $(SOURCES_DATA) +# The extension installation artifacts are stored in the dist subdirectory +$(NEW_EXTENSION_ARTIFACT): $(SOURCES_DATA) rm -f $@ cat $(SOURCES_DATA_DIR)/*.sql >> $@ +# The PGXS build infraestructure takes the control file from this +# directory, but for consistency we will copy the control file to +# the dist subdirectory too. dist/$(EXTENSION).control: $(EXTENSION).control cp $< $@ -REGRESS = $(notdir $(basename $(wildcard test/sql/*test.sql))) -TEST_DIR = test +all: dist/$(EXTENSION).control + +REGRESS = $(notdir $(basename $(wildcard test/$(EXTVERSION)/sql/*test.sql))) +TEST_DIR = test/$(EXTVERSION) REGRESS_OPTS = --inputdir='$(TEST_DIR)' --outputdir='$(TEST_DIR)' PG_CONFIG = pg_config diff --git a/pg/sql/poc_xyz.sql b/pg/sql/0.0.1/poc_xyz.sql similarity index 100% rename from pg/sql/poc_xyz.sql rename to pg/sql/0.0.1/poc_xyz.sql diff --git a/pg/test/expected/01_install_test.out b/pg/test/0.0.1/expected/01_install_test.out similarity index 100% rename from pg/test/expected/01_install_test.out rename to pg/test/0.0.1/expected/01_install_test.out diff --git a/pg/test/expected/02_poc_xyz_test.out b/pg/test/0.0.1/expected/02_poc_xyz_test.out similarity index 100% rename from pg/test/expected/02_poc_xyz_test.out rename to pg/test/0.0.1/expected/02_poc_xyz_test.out diff --git a/pg/test/0.0.1/results/01_install_test.out b/pg/test/0.0.1/results/01_install_test.out new file mode 100644 index 0000000..26bd1bf --- /dev/null +++ b/pg/test/0.0.1/results/01_install_test.out @@ -0,0 +1,4 @@ +-- Install dependencies +CREATE EXTENSION plpythonu; +-- Install the extension +CREATE EXTENSION crankshaft; diff --git a/pg/test/0.0.1/results/02_poc_xyz_test.out b/pg/test/0.0.1/results/02_poc_xyz_test.out new file mode 100644 index 0000000..bb23ea2 --- /dev/null +++ b/pg/test/0.0.1/results/02_poc_xyz_test.out @@ -0,0 +1,6 @@ +SELECT cdb_crankshaft.cdb_poc_xyz(); + cdb_poc_xyz +------------- + xyz-result +(1 row) + diff --git a/pg/test/sql/01_install_test.sql b/pg/test/0.0.1/sql/01_install_test.sql similarity index 100% rename from pg/test/sql/01_install_test.sql rename to pg/test/0.0.1/sql/01_install_test.sql diff --git a/pg/test/sql/02_poc_xyz_test.sql b/pg/test/0.0.1/sql/02_poc_xyz_test.sql similarity index 100% rename from pg/test/sql/02_poc_xyz_test.sql rename to pg/test/0.0.1/sql/02_poc_xyz_test.sql