Skip to content
This repository was archived by the owner on Jul 8, 2022. It is now read-only.

Commit 364cc9e

Browse files
authored
Merge pull request #673 from t-b/switch-to-python3-for-tests
Switch to python3 for tests
2 parents 960163b + 6c936fa commit 364cc9e

File tree

9 files changed

+25
-23
lines changed

9 files changed

+25
-23
lines changed

.travis/debian10/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ RUN apt-get update && apt-get install -y \
2020
libzmq3-dev \
2121
lsb-release \
2222
omniidl \
23-
python2
23+
python3
2424

2525
RUN apt-get install -y \
2626
apt-transport-https \

.travis/debian8/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ RUN apt-get update && apt-get install -y \
2121
libcos4-dev \
2222
libomnithread3-dev \
2323
libzmq3-dev \
24+
python3 \
2425
wget
2526

2627
RUN wget --no-check-certificate https://cmake.org/files/v3.10/cmake-3.10.0-Linux-x86_64.sh -O /tmp/cmake-install.sh \

.travis/debian9/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ RUN apt-get update && apt-get install -y \
1919
libomniorb4-dev \
2020
libcos4-dev \
2121
libomnithread3-dev \
22+
python3 \
2223
libzmq3-dev
2324

2425
RUN apt-get install -y \

.travis/gcc-latest/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ RUN apt-get update && apt-get install -y \
2020
libzmq3-dev \
2121
lsb-release \
2222
omniidl \
23-
python2
23+
python3
2424

2525
RUN groupadd -g "$APP_GID" tango
2626

.travis/llvm-latest/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ RUN apt-get update && apt-get install -y \
2323
libzmq3-dev \
2424
lsb-release \
2525
omniidl \
26-
python2
26+
python3
2727

2828
RUN curl https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \
2929
echo "deb http://apt.llvm.org/buster/ llvm-toolchain-buster-${LLVM_VERSION} main" | tee -a /etc/apt/sources.list && \

.travis/ubuntu-20.04/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ RUN apt-get update && apt-get install -y \
2020
libzmq3-dev \
2121
lsb-release \
2222
omniidl \
23-
python2 \
23+
python3 \
2424
docker.io
2525

2626
RUN groupadd -g "$APP_GID" tango

cpp_test_suite/build_runner.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
set REL_DIR=..\..\..\..\
2-
python %REL_DIR%cxxtest\bin\cxxtestgen.py --template=%REL_DIR%cxxtest\template\tango_template.tpl -o runner.cpp ^
2+
python3 %REL_DIR%cxxtest\bin\cxxtestgen.py --template=%REL_DIR%cxxtest\template\tango_template.tpl -o runner.cpp ^
33
%REL_DIR%new_tests\cxx_syntax.cpp ^
44
%REL_DIR%new_tests\cxx_poll.cpp ^
55
%REL_DIR%new_tests\cxx_poll_admin.cpp ^
@@ -29,7 +29,7 @@ python %REL_DIR%cxxtest\bin\cxxtestgen.py --template=%REL_DIR%cxxtest\template\t
2929
%REL_DIR%new_tests\cxx_fwd_att.cpp ^
3030
%REL_DIR%new_tests\cxx_pipe_conf.cpp ^
3131
%REL_DIR%new_tests\cxx_pipe.cpp ^
32-
%REL_DIR%new_tests\cxx_z00_dyn_cmd.cpp
32+
%REL_DIR%new_tests\cxx_z00_dyn_cmd.cpp
3333

3434
rem %REL_DIR%new_tests\cxx_zmcast01_simple.cpp ^
3535
rem %REL_DIR%new_tests\cxx_zmcast02_local_remote.cpp ^

cpp_test_suite/cxxtest/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
find_package (Threads REQUIRED)
2-
find_program(PYTHON_INTERPRETER NAMES python2 python)
2+
find_program(PYTHON_INTERPRETER NAMES python3)
33

44
if(NOT PYTHON_INTERPRETER)
5-
message(SEND_ERROR "Could not find python 2.")
5+
message(FATAL_ERROR "Could not find python 3.")
66
endif()
77

88
macro(CXX_GENERATE_TEST name)
@@ -16,7 +16,7 @@ macro(CXX_GENERATE_TEST name)
1616
RESULT_VARIABLE GENERATOR_OUTPUT)
1717

1818
if(NOT EXISTS ${GENERATED_FILE})
19-
message(SEND_ERROR " Failed to generate ${name}.cpp due to \"${GENERATOR_OUTPUT}\".")
19+
message(FATAL_ERROR " Failed to generate ${name}.cpp due to \"${GENERATOR_OUTPUT}\".")
2020
endif()
2121

2222
add_executable(${name} $<TARGET_OBJECTS:compare_test_object> ${name}.cpp)

cpp_test_suite/cxxtest/bin/cxxtestgen.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python
1+
#!/usr/bin/env python3
22
'''Usage: %s [OPTIONS] <input file(s)>
33
Generate test source file for CxxTest.
44
@@ -57,7 +57,7 @@ def main():
5757
def usage( problem = None ):
5858
'''Print usage info and exit'''
5959
if problem is None:
60-
print usageString()
60+
print(usageString())
6161
sys.exit(0)
6262
else:
6363
sys.stderr.write( usageString() )
@@ -82,7 +82,7 @@ def parseCommandline():
8282
'error-printer', 'abort-on-fail', 'have-std', 'no-std',
8383
'have-eh', 'no-eh', 'template=', 'include=',
8484
'root', 'part', 'no-static-init', 'factor', 'longlong='] )
85-
except getopt.error, problem:
85+
except getopt.error as problem:
8686
usage( problem )
8787
setOptions( options )
8888
return setFiles( patterns )
@@ -147,7 +147,7 @@ def printVersion():
147147
def setFiles( patterns ):
148148
'''Set input files specified on command line'''
149149
files = expandWildcards( patterns )
150-
if len(files) is 0 and not root:
150+
if len(files) == 0 and not root:
151151
usage( "No input files found" )
152152
return files
153153

@@ -169,7 +169,7 @@ def scanInputFiles(files):
169169
for file in files:
170170
scanInputFile(file)
171171
global suites
172-
if len(suites) is 0 and not root:
172+
if len(suites) == 0 and not root:
173173
abort( 'No tests defined' )
174174

175175
def scanInputFile(fileName):
@@ -288,7 +288,7 @@ def addLineToBlock( suite, lineNo, line ):
288288
'''Append the line to the current CXXTEST_CODE() block'''
289289
line = fixBlockLine( suite, lineNo, line )
290290
line = re.sub( r'^.*\{\{', '', line )
291-
291+
292292
e = re.search( r'\}\}', line )
293293
if e:
294294
line = line[:e.start()]
@@ -315,30 +315,30 @@ def scanLineForDestroy( suite, lineNo, line ):
315315

316316
def cstr( str ):
317317
'''Convert a string to its C representation'''
318-
return '"' + string.replace( str, '\\', '\\\\' ) + '"'
318+
return '"' + str.replace('\\', '\\\\' ) + '"'
319319

320320

321321
def addSuiteCreateDestroy( suite, which, line ):
322322
'''Add createSuite()/destroySuite() to current suite'''
323-
if suite.has_key(which):
323+
if which in suite:
324324
abort( '%s:%s: %sSuite() already declared' % ( suite['file'], str(line), which ) )
325325
suite[which] = line
326326

327327
def closeSuite():
328328
'''Close current suite and add it to the list if valid'''
329329
global suite
330330
if suite is not None:
331-
if len(suite['tests']) is not 0:
331+
if len(suite['tests']) != 0:
332332
verifySuite(suite)
333333
rememberSuite(suite)
334334
suite = None
335335

336336
def verifySuite(suite):
337337
'''Verify current suite is legal'''
338-
if suite.has_key('create') and not suite.has_key('destroy'):
338+
if 'create' in suite and 'destroy' not in suite:
339339
abort( '%s:%s: Suite %s has createSuite() but no destroySuite()' %
340340
(suite['file'], suite['create'], suite['name']) )
341-
if suite.has_key('destroy') and not suite.has_key('create'):
341+
if 'destroy' in suite and 'create' not in suite:
342342
abort( '%s:%s: Suite %s has destroySuite() but no createSuite()' %
343343
(suite['file'], suite['destroy'], suite['name']) )
344344

@@ -474,7 +474,7 @@ def isGenerated(suite):
474474

475475
def isDynamic(suite):
476476
'''Checks whether a suite is dynamic'''
477-
return suite.has_key('create')
477+
return 'create' in suite
478478

479479
lastIncluded = ''
480480
def writeInclude(output, file):
@@ -533,11 +533,11 @@ def runBody( suite, test ):
533533
def dynamicRun( suite, test ):
534534
'''Body of TestDescription::run() for test in a dynamic suite'''
535535
return 'if ( ' + suite['object'] + ' ) ' + suite['object'] + '->' + test['name'] + '();'
536-
536+
537537
def staticRun( suite, test ):
538538
'''Body of TestDescription::run() for test in a non-dynamic suite'''
539539
return suite['object'] + '.' + test['name'] + '();'
540-
540+
541541
def writeSuiteDescription( output, suite ):
542542
'''Write SuiteDescription object'''
543543
if isDynamic( suite ):

0 commit comments

Comments
 (0)