Merge branch 'remove-dependency-on-2to3'
* remove-dependency-on-2to3: Remove need for Python 2to3 Modify examples to be both Python 2 and 3 compatible Remove python3 specific runme3.py test files Convert python tests using 2to3 Convert python test scripts to be Python 2 and 3 compatible Convert swigobject python test to be python 2 and 3 compatible Convert two tests to work with both Python 2 and 3 Improve director_exception Python test Remove further print statements from Python tests Improve Python testing catching exceptions Improve contract Python testcase testing Remove print statements from Python tests
This commit is contained in:
commit
baec830f75
147 changed files with 1193 additions and 1427 deletions
|
|
@ -10,20 +10,10 @@ endif
|
|||
|
||||
LANGUAGE = python
|
||||
PYTHON = $(PYBIN)
|
||||
SCRIPTSUFFIX = _runme.py
|
||||
PYCODESTYLE = @PYCODESTYLE@
|
||||
PYCODESTYLE_FLAGS = --ignore=E252,E30,E402,E501,E731,E741,W291,W391
|
||||
|
||||
#*_runme.py for Python 2.x, *_runme3.py for Python 3.x
|
||||
PY2SCRIPTSUFFIX = _runme.py
|
||||
PY3SCRIPTSUFFIX = _runme3.py
|
||||
PY2TO3 = @PY2TO3@ -x import
|
||||
|
||||
ifeq (,$(PY3))
|
||||
SCRIPTSUFFIX = $(PY2SCRIPTSUFFIX)
|
||||
else
|
||||
SCRIPTSUFFIX = $(PY3SCRIPTSUFFIX)
|
||||
endif
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
|
|
@ -108,7 +98,6 @@ C_TEST_CASES += \
|
|||
include $(srcdir)/../common.mk
|
||||
|
||||
# Overridden variables here
|
||||
SCRIPTDIR = .
|
||||
LIBS = -L.
|
||||
VALGRIND_OPT += --suppressions=pythonswig.supp
|
||||
|
||||
|
|
@ -117,35 +106,25 @@ VALGRIND_OPT += --suppressions=pythonswig.supp
|
|||
|
||||
# Rules for the different types of tests
|
||||
%.cpptest:
|
||||
+$(convert_testcase)
|
||||
$(setup)
|
||||
+$(swig_and_compile_cpp)
|
||||
$(check_pep8)
|
||||
$(run_testcase)
|
||||
|
||||
%.ctest:
|
||||
+$(convert_testcase)
|
||||
$(setup)
|
||||
+$(swig_and_compile_c)
|
||||
$(check_pep8)
|
||||
$(run_testcase)
|
||||
|
||||
%.multicpptest:
|
||||
+$(convert_testcase)
|
||||
$(setup)
|
||||
+$(swig_and_compile_multi_cpp)
|
||||
$(check_pep8_multi_cpp)
|
||||
$(run_testcase)
|
||||
|
||||
|
||||
|
||||
# Runs the testcase. A testcase is only run if
|
||||
# a file is found which has _runme.py (or _runme3.py for Python 3) appended after the testcase name.
|
||||
|
||||
py_runme = $(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)
|
||||
py2_runme = $(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX)
|
||||
py3_runme = $(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX)
|
||||
|
||||
# Python code style checking
|
||||
ifneq (,$(PYCODESTYLE))
|
||||
check_pep8 = $(COMPILETOOL) $(PYCODESTYLE) $(PYCODESTYLE_FLAGS) $(SCRIPTPREFIX)$*.py
|
||||
|
||||
|
|
@ -155,70 +134,16 @@ check_pep8_multi_cpp = \
|
|||
done
|
||||
endif
|
||||
|
||||
run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=.:$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(py_runme)
|
||||
|
||||
# Runs the testcase. A testcase is only run if
|
||||
# a file is found which has _runme.py appended after the testcase name.
|
||||
run_testcase = \
|
||||
if [ -f $(SCRIPTDIR)/$(py_runme) ]; then \
|
||||
$(run_python);\
|
||||
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=.:$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
fi
|
||||
|
||||
# Grab runme file ready for running: copied for out of source tree builds, and/or run 2to3
|
||||
# Note terminal (double colon) rules creating runme files to fix possible infinite recursion,
|
||||
# see https://github.com/swig/swig/pull/688
|
||||
ifeq ($(SCRIPTDIR),$(srcdir))
|
||||
# in source tree build
|
||||
ifeq (,$(PY3))
|
||||
convert_testcase =
|
||||
else
|
||||
convert_testcase = \
|
||||
if [ -f $(srcdir)/$(py2_runme) ]; then \
|
||||
$(MAKE) $(SCRIPTDIR)/$(py_runme); \
|
||||
fi
|
||||
|
||||
# For converting python 2 tests into Python 3 tests
|
||||
$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX):: $(srcdir)/$(SCRIPTPREFIX)%$(PY2SCRIPTSUFFIX)
|
||||
cp $< $@
|
||||
$(PY2TO3) -w $@ >/dev/null 2>&1
|
||||
|
||||
endif
|
||||
else
|
||||
# out of source tree build
|
||||
ifeq (,$(PY3))
|
||||
convert_testcase = \
|
||||
if [ -f $(srcdir)/$(py2_runme) ]; then \
|
||||
$(MAKE) $(SCRIPTDIR)/$(py_runme); \
|
||||
fi
|
||||
|
||||
$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX):: $(srcdir)/$(SCRIPTPREFIX)%$(PY2SCRIPTSUFFIX)
|
||||
cp $< $@
|
||||
|
||||
else
|
||||
convert_testcase = \
|
||||
if [ -f $(srcdir)/$(py2_runme) ]; then \
|
||||
$(MAKE) $(SCRIPTDIR)/$(py_runme); \
|
||||
elif [ -f $(srcdir)/$(py3_runme) ]; then \
|
||||
$(MAKE) $(SCRIPTDIR)/$(py3_runme); \
|
||||
fi
|
||||
|
||||
# For when there is a _runme3.py instead of a _runme.py, ie a Python 3 only run test
|
||||
$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX):: $(srcdir)/$(SCRIPTPREFIX)%$(PY3SCRIPTSUFFIX)
|
||||
cp $< $@
|
||||
|
||||
# For converting python 2 tests into Python 3 tests
|
||||
$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX):: $(srcdir)/$(SCRIPTPREFIX)%$(PY2SCRIPTSUFFIX)
|
||||
cp $< $@
|
||||
$(PY2TO3) -w $@ >/dev/null 2>&1
|
||||
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
# Clean: remove the generated .py file
|
||||
# We only remove the _runme3.py if it is generated by 2to3 from a _runme.py.
|
||||
%.clean:
|
||||
@rm -f $*.py
|
||||
@if test -f $(srcdir)/$(py2_runme); then rm -f $(SCRIPTDIR)/$(py3_runme) $(SCRIPTDIR)/$(py3_runme).bak; fi
|
||||
@if test "x$(SCRIPTDIR)" != "x$(srcdir)"; then rm -f $(SCRIPTDIR)/$(py_runme); fi
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' python_clean
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue