You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kg...@apache.org on 2018/06/01 15:00:15 UTC

[05/11] qpid-dispatch git commit: DISPATCH-965: restrict tox version, fixup 2.6 issues

DISPATCH-965: restrict tox version, fixup 2.6 issues


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/fb363cb5
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/fb363cb5
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/fb363cb5

Branch: refs/heads/master
Commit: fb363cb55411eb96667f63637d0a1cacb56df655
Parents: 7bdd55c
Author: Kenneth Giusti <kg...@redhat.com>
Authored: Tue May 15 20:56:12 2018 -0400
Committer: Kenneth Giusti <kg...@redhat.com>
Committed: Wed May 16 00:24:41 2018 -0400

----------------------------------------------------------------------
 .../qpid_dispatch_internal/management/schema.py |  1 +
 src/entity.c                                    |  7 ++++
 tests/CMakeLists.txt                            | 37 ++++++++++++++------
 tests/tox.ini.in                                | 27 ++++++++++++++
 tox.ini                                         | 34 ------------------
 5 files changed, 62 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/fb363cb5/python/qpid_dispatch_internal/management/schema.py
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch_internal/management/schema.py b/python/qpid_dispatch_internal/management/schema.py
index 227f96a..f42cf10 100644
--- a/python/qpid_dispatch_internal/management/schema.py
+++ b/python/qpid_dispatch_internal/management/schema.py
@@ -116,6 +116,7 @@ class EnumValue(str):
 
     def __hash__(self): return super(EnumValue, self).__hash__()
     def __int__(self): return self.value
+    def __long__(self): return self.value
     def __eq__(self, x): return str(self) == x or int(self) == x
     def __ne__(self, x): return not self == x
     def __repr__(self): return "EnumValue('%s', %s)"%(str(self), int(self))

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/fb363cb5/src/entity.c
----------------------------------------------------------------------
diff --git a/src/entity.c b/src/entity.c
index 59717ab..9bcf6fa 100644
--- a/src/entity.c
+++ b/src/entity.c
@@ -54,6 +54,13 @@ char *qd_entity_get_string(qd_entity_t *entity, const char* attribute) {
 long qd_entity_get_long(qd_entity_t *entity, const char* attribute) {
     qd_error_clear();
     PyObject *py_obj = qd_entity_get_py(entity, attribute);
+    if (py_obj && !PyLong_Check(py_obj)) {
+        // 2.6 PyLong_AsLong fails to 'cast' non-long types
+        // so we have to manually cast it first:
+        PyObject *py_tmp = PyNumber_Long(py_obj);
+        Py_XDECREF(py_obj);
+        py_obj = py_tmp;
+    }
     long result = py_obj ? PyLong_AsLong(py_obj) : -1;
     Py_XDECREF(py_obj);
     qd_error_py();

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/fb363cb5/tests/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 11bf33c..77c4c4d 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -117,19 +117,36 @@ foreach(py_test_module
 endforeach()
 
 # Use tox to run the flake8 python linter tool on all the python
-# sources. Highly recommended if you're hacking the python code
+# sources. Highly recommended if you're hacking the python code.
+# Unfortunately this can only be done for versions of tox >= 1.9.0
+# since that version allows us to skip the install step (we have
+# no modules thus no setup.py)
 #
 find_program(TOX_EXE "tox")
 if (TOX_EXE)
-  add_test (NAME python-checker
-            COMMAND ${TOX_EXE}
-            WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
-  # Once we move to tox >= v1.7.2 we can remove the next
-  # line.  See tox.ini file for details
-  set_tests_properties(python-checker
-                       PROPERTIES
-                       PASS_REGULAR_EXPRESSION "commands succeeded"
-                       FAIL_REGULAR_EXPRESSION "commands failed")
+  set(TOX_MIN_VERSION 1.9.0)
+  execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import tox, sys; print('%s' % tox.__version__); sys.exit(0)"
+                  RESULT_VARIABLE TOX_STATUS
+                  OUTPUT_VARIABLE TOX_VERSION)
+  if (TOX_STATUS EQUAL 0)
+    string(STRIP ${TOX_VERSION} TOX_VERSION)
+    if (TOX_VERSION STRLESS TOX_MIN_VERSION)
+      message( STATUS "tox version ${TOX_VERSION} < required version ${TOX_MIN_VERSION} - skipping python-checker")
+    else (TOX_VERSION STRLESS TOX_MIN_VERSION)
+      configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tox.ini.in ${CMAKE_CURRENT_BINARY_DIR}/tox.ini)
+      add_test (NAME python-checker
+                COMMAND ${TOX_EXE}
+                WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+      # Once we move to tox >= v1.7.2 we can remove the next
+      # line.  See tox.ini file for details
+      set_tests_properties(python-checker
+                           PROPERTIES
+                           PASS_REGULAR_EXPRESSION "commands succeeded"
+                           FAIL_REGULAR_EXPRESSION "commands failed")
+    endif (TOX_VERSION STRLESS TOX_MIN_VERSION)
+  else (TOX_STATUS EQUAL 0)
+    message(STATUS "Cannot determine tox version - skipping python-checker")
+  endif (TOX_STATUS EQUAL 0)
 
 else (TOX_EXE)
   message(STATUS "Could NOT find 'tox' tool - unable to validate python code")

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/fb363cb5/tests/tox.ini.in
----------------------------------------------------------------------
diff --git a/tests/tox.ini.in b/tests/tox.ini.in
new file mode 100644
index 0000000..d431628
--- /dev/null
+++ b/tests/tox.ini.in
@@ -0,0 +1,27 @@
+[tox]
+envlist = py27,py35,py36
+skipsdist = True
+minversion = ${TOX_VERSION}
+skip_missing_interpreters = True
+skip_install = True
+
+[testenv]
+# we ignore lots of errors/warnings we probably should not,
+# but it will take a lot of effort to make the code PEP8 compliant...
+commands = flake8 --count ${CMAKE_SOURCE_DIR}/python ${CMAKE_SOURCE_DIR}/console ${CMAKE_SOURCE_DIR}/doc ${CMAKE_SOURCE_DIR}/tests ${CMAKE_SOURCE_DIR}/tools --show-source --ignore=E111,E114,E121,E122,E123,E124,E126,E127,E128,E131,E201,E202,E203,E211,E221,E222,E225,E226,E228,E231,E241,E251,E261,E266,E265,E271,E272,E301,E302,E303,E401,E402,E501,E502,E701,E702,E703,E704,E711,E712,E713,E714,E731,F401,F403,F405,F811,F841,H101,H102,H104,H201,H202,H234,H237,H238,H301,H306,H401,H403,H404,H405,W291,W292,W293,W391,W503
+deps = hacking>=1.1.0
+
+# flake8 no longer supports python2.6
+# [testenv:py26]
+# basepython = python2.6
+
+[testenv:py27]
+basepython = python2.7
+
+[testenv:py35]
+basepython = python3.5
+
+[testenv:py36]
+basepython = python3.6
+
+

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/fb363cb5/tox.ini
----------------------------------------------------------------------
diff --git a/tox.ini b/tox.ini
deleted file mode 100644
index 6f749fd..0000000
--- a/tox.ini
+++ /dev/null
@@ -1,34 +0,0 @@
-[tox]
-envlist = py27,py35,py36
-skipsdist = True
-minversion = 1.4
-# note: when minversion is >= 1.7.2, uncomment the
-# following and remove the PASS/FAIL regular expression
-# property in CMakeLists.txt
-# This setting makes tox not treat missing environments as errors:
-#skip_missing_interpreters = True
-
-[testenv]
-commands = flake8 --count python console doc tests tools
-deps = hacking
-
-# flake8 no longer supports python2.6
-# [testenv:py26]
-# basepython = python2.6
-
-[testenv:py27]
-basepython = python2.7
-
-[testenv:py35]
-basepython = python3.5
-
-[testenv:py36]
-basepython = python3.6
-
-[flake8]
-show-source = True
-# we really need to check for some of these, but the
-# code will need lots of work to correct this issues
-ignore = E111,E114,E121,E122,E123,E124,E126,E127,E128,E131,E201,E202,E203,E211,E221,E222,E225,E226,E228,E231,E241,E251,E261,E266,E265,E271,E272,E301,E302,E303,E401,E402,E501,E502,E701,E702,E703,E704,E711,E712,E713,E714,E731,F401,F403,F405,F811,F841,H101,H102,H104,H201,H202,H234,H237,H238,H301,H306,H401,H403,H404,H405,W291,W292,W293,W391,W503
-
-


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org