Skip to content

Commit b2e3bea

Browse files
committed
PL/Python: Improve Python 3 regression test setup
Currently, we are making mangled copies of plpython/{expected,sql} to plpython/python3/{expected,sql}, and run the tests in plpython/python3. This has the disadvantage that the regression.diffs file, if any, ends up in plpython/python3, which is not the normal location. If we instead make the mangled copies in plpython/{expected,sql}/python3/, we can run the tests from the normal directory, regression.diffs ends up the normal place, and the pg_regress invocation also becomes a lot simpler. It's also more obvious at run time what's going on, because the tests end up being named "python3/something" in the test output.
1 parent 3b8968f commit b2e3bea

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

src/pl/plpython/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/spiexceptions.h
22
# Generated subdirectories
3+
/expected/python3/
34
/log/
45
/results/
6+
/sql/python3/
57
/tmp_check/

src/pl/plpython/Makefile

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ REGRESS = \
103103
plpython_subtransaction \
104104
plpython_drop
105105

106+
REGRESS_PLPYTHON3_MANGLE := $(REGRESS)
107+
106108
# where to find psql for running the tests
107109
PSQLDIR = $(bindir)
108110

@@ -129,9 +131,20 @@ uninstall-data:
129131

130132
ifeq ($(python_majorversion),3)
131133
# Adjust regression tests for Python 3 compatibility
132-
prep3:
133-
$(MKDIR_P) python3 python3/sql python3/expected
134-
for file in $(srcdir)/sql/*.sql $(srcdir)/expected/*.out; do \
134+
#
135+
# Mention those regression test files that need to be mangled in the
136+
# variable REGRESS_PLPYTHON3_MANGLE. They will be copied to a
137+
# subdirectory python3/ and have their Python syntax and other bits
138+
# adjusted to work with Python 3.
139+
140+
# Note that the order of the tests needs to be preserved in this
141+
# expression.
142+
REGRESS := $(foreach test,$(REGRESS),$(if $(filter $(test),$(REGRESS_PLPYTHON3_MANGLE)),python3/$(test),$(test)))
143+
144+
.PHONY: pgregress-python3-mangle
145+
pgregress-python3-mangle:
146+
$(MKDIR_P) sql/python3 expected/python3 results/python3
147+
for file in $(patsubst %,$(srcdir)/sql/%.sql,$(REGRESS_PLPYTHON3_MANGLE)) $(patsubst %,$(srcdir)/expected/%*.out,$(REGRESS_PLPYTHON3_MANGLE)); do \
135148
sed -e 's/except \([[:alpha:]][[:alpha:].]*\), *\([[:alpha:]][[:alpha:]]*\):/except \1 as \2:/g' \
136149
-e "s/<type 'exceptions\.\([[:alpha:]]*\)'>/<class '\1'>/g" \
137150
-e "s/<type 'long'>/<class 'int'>/g" \
@@ -143,26 +156,22 @@ prep3:
143156
-e "s/LANGUAGE plpython2u/LANGUAGE plpython3u/g" \
144157
-e "s/EXTENSION plpythonu/EXTENSION plpython3u/g" \
145158
-e "s/EXTENSION plpython2u/EXTENSION plpython3u/g" \
146-
$$file >`echo $$file | sed 's,^.*\(/[^/][^/]*/[^/][^/]*\)$$,python3\1,'` || exit; \
159+
$$file >`echo $$file | sed 's,^.*/\([^/][^/]*/\)\([^/][^/]*\)$$,\1python3/\2,'` || exit; \
147160
done
148161

149-
clean3:
150-
rm -rf python3/
162+
check installcheck: pgregress-python3-mangle
163+
164+
pg_regress_clean_files += sql/python3/ expected/python3/ results/python3/
151165

152-
check: all submake prep3
153-
$(pg_regress_check) --inputdir=./python3 --outputdir=./python3 $(REGRESS_OPTS) $(REGRESS)
166+
endif # Python 3
154167

155-
installcheck: submake prep3
156-
$(pg_regress_installcheck) --inputdir=./python3 --outputdir=./python3 $(REGRESS_OPTS) $(REGRESS)
157168

158-
clean: clean3
159-
else # not Python 3
160169
check: all submake
161170
$(pg_regress_check) $(REGRESS_OPTS) $(REGRESS)
162171

163172
installcheck: submake
164173
$(pg_regress_installcheck) $(REGRESS_OPTS) $(REGRESS)
165-
endif # not Python 3
174+
166175

167176
.PHONY: submake
168177
submake:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy