From eb02ca4d86ebc362f82ffcaac6159c4f876d5d81 Mon Sep 17 00:00:00 2001 From: Raul Marin Date: Mon, 28 Oct 2019 17:09:51 +0100 Subject: [PATCH] Regress: Allow variables in the tests --- Makefile | 30 +++++++++++++++++++++++++----- sql/test_setup.sql | 2 +- test/CDB_Username_expect | 2 +- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 99682e4..c62a95b 100644 --- a/Makefile +++ b/Makefile @@ -139,6 +139,8 @@ PLPYTHONU := plpythonu ifeq ($(PG_12_GE), true) PLPYTHONU := plpython3u endif +PGPORT ?= '5432' +PGUSER ?= 'postgres' $(EXTENSION)--$(EXTVERSION).sql: $(CDBSCRIPTS) cartodb_version.sql Makefile echo '\echo Use "CREATE EXTENSION $(EXTENSION)" to load this file. \quit' > $@ @@ -172,7 +174,7 @@ legacy_regress: $(REGRESS_OLD) Makefile mkdir -p expected/test/ mkdir -p results/test/ cat sql/test_setup.sql | \ - $(SED) -e 's/@@VERSION@@/$(EXTVERSION)/' -e 's/@extschema@/cartodb/g' -e "s/@postgisschema@/public/g" -e 's/plpythonu/$(PLPYTHONU)/g' \ + $(SED) -e 's/@@VERSION@@/$(EXTVERSION)/' -e 's/@extschema@/cartodb/g' -e "s/@postgisschema@/public/g" -e 's/@@plpythonu@@/$(PLPYTHONU)/g' \ > sql/test/test_setup.sql cp sql/test_setup_expect expected/test/test_setup.out for f in $(REGRESS_OLD); do \ @@ -183,10 +185,23 @@ legacy_regress: $(REGRESS_OLD) Makefile echo '\t' >> $${of}; \ echo '\set QUIET off' >> $${of}; \ cat $${f} | \ - $(SED) -e 's/@@VERSION@@/$(EXTVERSION)/' -e 's/@extschema@/cartodb/g' -e "s/@postgisschema@/public/g" -e 's/plpythonu/$(PLPYTHONU)/g' >> $${of}; \ + $(SED) -e 's/@@VERSION@@/$(EXTVERSION)/' \ + -e 's/@extschema@/cartodb/g' \ + -e "s/@postgisschema@/public/g" \ + -e 's/@@plpythonu@@/$(PLPYTHONU)/g' \ + -e 's/@@PGPORT@@/$(PGPORT)/g' \ + -e 's/@@PGUSER@@/$(PGUSER)/g' \ + >> $${of}; \ exp=expected/test/$${tn}.out; \ echo '\set ECHO none' > $${exp}; \ - cat test/$${tn}_expect >> $${exp}; \ + cat test/$${tn}_expect | \ + $(SED) -e 's/@@VERSION@@/$(EXTVERSION)/' \ + -e 's/@extschema@/cartodb/g' \ + -e "s/@postgisschema@/public/g" \ + -e 's/@@plpythonu@@/$(PLPYTHONU)/g' \ + -e 's/@@PGPORT@@/$(PGPORT)/g' \ + -e 's/@@PGUSER@@/$(PGUSER)/g' \ + >> $${exp}; \ done test_organization: @@ -198,8 +213,13 @@ test_extension_new: legacy_tests: legacy_regress $(EXTENSION)--unpackaged--$(EXTVERSION).sql PGREGRESS := $(shell dirname `$(PG_CONFIG) --pgxs`)/../../src/test/regress/pg_regress +PGBINDIR := $(shell $(PG_CONFIG) --bindir) +PGDATABASE = 'contrib_regression' regress: legacy_tests - $(PGREGRESS) --inputdir=./ --bindir='/usr/bin' --dbname=contrib_regression $(REGRESS) + PGUSER=$(PGUSER) \ + PGPORT=$(PGPORT) \ + $(PGREGRESS) --inputdir=./ --bindir='$(PGBINDIR)' --dbname=$(PGDATABASE) $(REGRESS) -installcheck: legacy_tests test_extension_new test_organization +installcheck: test_extension_new test_organization + $(MAKE) -C regress diff --git a/sql/test_setup.sql b/sql/test_setup.sql index ec5021b..cf55bf4 100644 --- a/sql/test_setup.sql +++ b/sql/test_setup.sql @@ -2,7 +2,7 @@ \set QUIET on SET client_min_messages TO error; CREATE EXTENSION postgis; -CREATE EXTENSION plpythonu; +CREATE EXTENSION @@plpythonu@@; CREATE SCHEMA cartodb; \i 'cartodb--unpackaged--@@VERSION@@.sql' CREATE FUNCTION public.cdb_invalidate_varnish(table_name text) diff --git a/test/CDB_Username_expect b/test/CDB_Username_expect index fe1ea5b..d030a42 100644 --- a/test/CDB_Username_expect +++ b/test/CDB_Username_expect @@ -1,4 +1,4 @@ -postgres +@@PGUSER@@ fulano fulanito