@@ -10,20 +10,10 @@ endif
10
10
11
11
LANGUAGE = python
12
12
PYTHON = $(PYBIN )
13
+ SCRIPTSUFFIX = _runme.py
13
14
PYCODESTYLE = @PYCODESTYLE@
14
15
PYCODESTYLE_FLAGS = --ignore=E252,E30,E402,E501,E731,E741,W291,W391
15
16
16
- # *_runme.py for Python 2.x, *_runme3.py for Python 3.x
17
- PY2SCRIPTSUFFIX = _runme.py
18
- PY3SCRIPTSUFFIX = _runme3.py
19
- PY2TO3 = @PY2TO3@ -x import
20
-
21
- ifeq (,$(PY3 ) )
22
- SCRIPTSUFFIX = $(PY2SCRIPTSUFFIX )
23
- else
24
- SCRIPTSUFFIX = $(PY3SCRIPTSUFFIX )
25
- endif
26
-
27
17
srcdir = @srcdir@
28
18
top_srcdir = @top_srcdir@
29
19
top_builddir = @top_builddir@
@@ -107,7 +97,6 @@ C_TEST_CASES += \
107
97
include $(srcdir ) /../common.mk
108
98
109
99
# Overridden variables here
110
- SCRIPTDIR = .
111
100
LIBS = -L.
112
101
VALGRIND_OPT += --suppressions=pythonswig.supp
113
102
@@ -116,35 +105,25 @@ VALGRIND_OPT += --suppressions=pythonswig.supp
116
105
117
106
# Rules for the different types of tests
118
107
% .cpptest :
119
- +$(convert_testcase )
120
108
$(setup )
121
109
+$(swig_and_compile_cpp )
122
110
$(check_pep8 )
123
111
$(run_testcase )
124
112
125
113
% .ctest :
126
- +$(convert_testcase )
127
114
$(setup )
128
115
+$(swig_and_compile_c )
129
116
$(check_pep8 )
130
117
$(run_testcase )
131
118
132
119
% .multicpptest :
133
- +$(convert_testcase )
134
120
$(setup )
135
121
+$(swig_and_compile_multi_cpp )
136
122
$(check_pep8_multi_cpp )
137
123
$(run_testcase )
138
124
139
125
140
-
141
- # Runs the testcase. A testcase is only run if
142
- # a file is found which has _runme.py (or _runme3.py for Python 3) appended after the testcase name.
143
-
144
- py_runme = $(SCRIPTPREFIX ) $* $(SCRIPTSUFFIX )
145
- py2_runme = $(SCRIPTPREFIX ) $* $(PY2SCRIPTSUFFIX )
146
- py3_runme = $(SCRIPTPREFIX ) $* $(PY3SCRIPTSUFFIX )
147
-
126
+ # Python code style checking
148
127
ifneq (,$(PYCODESTYLE ) )
149
128
check_pep8 = $(COMPILETOOL ) $(PYCODESTYLE ) $(PYCODESTYLE_FLAGS ) $(SCRIPTPREFIX ) $* .py
150
129
@@ -154,70 +133,16 @@ check_pep8_multi_cpp = \
154
133
done
155
134
endif
156
135
157
- run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=.: $( srcdir ) :$$PYTHONPATH $( RUNTOOL ) $( PYTHON ) $( py_runme )
158
-
136
+ # Runs the testcase. A testcase is only run if
137
+ # a file is found which has _runme.py appended after the testcase name.
159
138
run_testcase = \
160
- if [ -f $(SCRIPTDIR ) /$(py_runme ) ]; then \
161
- $(run_python ) ;\
162
- fi
163
-
164
- # Grab runme file ready for running: copied for out of source tree builds, and/or run 2to3
165
- # Note terminal (double colon) rules creating runme files to fix possible infinite recursion,
166
- # see https://github.com/swig/swig/pull/688
167
- ifeq ($(SCRIPTDIR ) ,$(srcdir ) )
168
- # in source tree build
169
- ifeq (,$(PY3))
170
- convert_testcase =
171
- else
172
- convert_testcase = \
173
- if [ -f $(srcdir ) /$(py2_runme ) ]; then \
174
- $(MAKE ) $(SCRIPTDIR ) /$(py_runme ) ; \
139
+ if [ -f $(SCRIPTDIR ) /$(SCRIPTPREFIX ) $* $(SCRIPTSUFFIX ) ]; then \
140
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=.:$(srcdir ) :$$PYTHONPATH $(RUNTOOL ) $(PYTHON ) $(SCRIPTDIR ) /$(SCRIPTPREFIX ) $* $(SCRIPTSUFFIX ) ; \
175
141
fi
176
142
177
- # For converting python 2 tests into Python 3 tests
178
- $(SCRIPTDIR ) /$(SCRIPTPREFIX ) % $(SCRIPTSUFFIX ) :: $(srcdir ) /$(SCRIPTPREFIX ) % $(PY2SCRIPTSUFFIX )
179
- cp $< $@
180
- $(PY2TO3 ) -w $@ > /dev/null 2>&1
181
-
182
- endif
183
- else
184
- # out of source tree build
185
- ifeq (,$(PY3))
186
- convert_testcase = \
187
- if [ -f $(srcdir ) /$(py2_runme ) ]; then \
188
- $(MAKE ) $(SCRIPTDIR ) /$(py_runme ) ; \
189
- fi
190
-
191
- $(SCRIPTDIR ) /$(SCRIPTPREFIX ) % $(SCRIPTSUFFIX ) :: $(srcdir ) /$(SCRIPTPREFIX ) % $(PY2SCRIPTSUFFIX )
192
- cp $< $@
193
-
194
- else
195
- convert_testcase = \
196
- if [ -f $(srcdir ) /$(py2_runme ) ]; then \
197
- $(MAKE ) $(SCRIPTDIR ) /$(py_runme ) ; \
198
- elif [ -f $(srcdir ) /$(py3_runme ) ]; then \
199
- $(MAKE ) $(SCRIPTDIR ) /$(py3_runme ) ; \
200
- fi
201
-
202
- # For when there is a _runme3.py instead of a _runme.py, ie a Python 3 only run test
203
- $(SCRIPTDIR ) /$(SCRIPTPREFIX ) % $(SCRIPTSUFFIX ) :: $(srcdir ) /$(SCRIPTPREFIX ) % $(PY3SCRIPTSUFFIX )
204
- cp $< $@
205
-
206
- # For converting python 2 tests into Python 3 tests
207
- $(SCRIPTDIR ) /$(SCRIPTPREFIX ) % $(SCRIPTSUFFIX ) :: $(srcdir ) /$(SCRIPTPREFIX ) % $(PY2SCRIPTSUFFIX )
208
- cp $< $@
209
- $(PY2TO3 ) -w $@ > /dev/null 2>&1
210
-
211
- endif
212
-
213
- endif
214
-
215
143
# Clean: remove the generated .py file
216
- # We only remove the _runme3.py if it is generated by 2to3 from a _runme.py.
217
144
% .clean :
218
145
@rm -f $* .py
219
- @if test -f $(srcdir ) /$(py2_runme ) ; then rm -f $(SCRIPTDIR ) /$(py3_runme ) $(SCRIPTDIR ) /$(py3_runme ) .bak; fi
220
- @if test " x$( SCRIPTDIR) " ! = " x$( srcdir) " ; then rm -f $(SCRIPTDIR ) /$(py_runme ) ; fi
221
146
222
147
clean :
223
148
$(MAKE ) -f $(top_builddir ) /$(EXAMPLES ) /Makefile SRCDIR=' $(SRCDIR)' python_clean
0 commit comments