Browse Source

Fix compilation with python3 and add python3 to CI

Fix #1213
Stefan Profanter 6 years ago
parent
commit
f94a6280f5

+ 2 - 2
tools/generate_datatypes.py

@@ -448,9 +448,9 @@ def iter_types(v):
     else:
         l = list(v.values())
     if len(selected_types) > 0:
-        l = filter(lambda t: t.name in selected_types, l)
+        l = list(filter(lambda t: t.name in selected_types, l))
     if args.no_builtin:
-        l = filter(lambda t: type(t) != BuiltinType, l)
+        l = list(filter(lambda t: type(t) != BuiltinType, l))
     return l
 
 ################

+ 2 - 4
tools/generate_statuscode_descriptions.py

@@ -20,7 +20,7 @@ f = open(args.statuscodes)
 input_str = f.read()
 f.close()
 input_str = input_str.replace('\r','')
-rows = map(lambda x:tuple(x.split(',')), input_str.split('\n'))
+rows = list(map(lambda x:tuple(x.split(',')), input_str.split('\n')))
 
 fc = open(args.outfile + ".c",'w')
 def printc(string):
@@ -36,9 +36,7 @@ printc('''/**********************************************************
 
 #include "ua_types.h"''')
 
-count = 2
-for row in rows:
-    count += 1
+count = 2 + len(rows)
 
 printc('''
 

+ 13 - 3
tools/travis/travis_linux_script.sh

@@ -193,12 +193,22 @@ else
     cd .. && rm build -rf
     echo -en 'travis_fold:end:script.build.multithread\\r'
 
-    echo -e "\r\n== Debug build and unit tests (64 bit) ==" && echo -en 'travis_fold:start:script.build.unit_test_valgrind\\r'
+    echo -e "\r\n== Debug build and unit tests (64 bit, python 2) ==" && echo -en 'travis_fold:start:script.build.unit_test_valgrind_python2\\r'
     mkdir -p build && cd build
-    cmake -DCMAKE_BUILD_TYPE=Debug -DUA_BUILD_EXAMPLES=ON -DUA_ENABLE_DISCOVERY=ON -DUA_ENABLE_DISCOVERY_MULTICAST=ON -DUA_BUILD_UNIT_TESTS=ON -DUA_ENABLE_COVERAGE=ON -DUA_ENABLE_VALGRIND_UNIT_TESTS=ON ..
+    # Force to use python2 to test compilation with python2
+    cmake -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python2 -DCMAKE_BUILD_TYPE=Debug -DUA_BUILD_EXAMPLES=ON -DUA_ENABLE_DISCOVERY=ON -DUA_ENABLE_DISCOVERY_MULTICAST=ON -DUA_BUILD_UNIT_TESTS=ON -DUA_ENABLE_COVERAGE=ON -DUA_ENABLE_VALGRIND_UNIT_TESTS=ON ..
     make -j && make test ARGS="-V"
     if [ $? -ne 0 ] ; then exit 1 ; fi
-    echo -en 'travis_fold:end:script.build.unit_test_valgrind\\r'
+    cd .. && rm build -rf
+    echo -en 'travis_fold:end:script.build.unit_test_valgrind_python2\\r'
+
+    echo -e "\r\n== Debug build and unit tests (64 bit, python 3) ==" && echo -en 'travis_fold:start:script.build.unit_test_valgrind_python3\\r'
+    mkdir -p build && cd build
+    # Force to use python3 to test compilation with python3
+    cmake -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3 -DCMAKE_BUILD_TYPE=Debug -DUA_BUILD_EXAMPLES=ON -DUA_ENABLE_DISCOVERY=ON -DUA_ENABLE_DISCOVERY_MULTICAST=ON -DUA_BUILD_UNIT_TESTS=ON -DUA_ENABLE_COVERAGE=ON -DUA_ENABLE_VALGRIND_UNIT_TESTS=ON ..
+    make -j && make test ARGS="-V"
+    if [ $? -ne 0 ] ; then exit 1 ; fi
+    echo -en 'travis_fold:end:script.build.unit_test_valgrind_python3\\r'
 
     # only run coveralls on main repo, otherwise it fails uploading the files
     echo -e "\r\n== -> Current repo: ${TRAVIS_REPO_SLUG} =="