[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libosinfo] [osinfo-db PATCH] Makefile: Do not remove xmllint check when building on older OSes



On 3/19/19 12:09 PM, Fabiano Fidêncio wrote:
Let's not remove the lint target as it can still be used by older OSes
which do not support python3.

Signed-off-by: Fabiano Fidêncio <fidencio redhat com>
---
  Makefile | 14 +++++++++++++-
  1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 0000306..5d904ff 100644
--- a/Makefile
+++ b/Makefile
@@ -32,6 +32,8 @@ ARCHIVE = osinfo-db-$(TODAY).tar.xz
ZANATA = zanata +XMLLINT = xmllint
+
  PYTHON = python3
V = 0
@@ -120,6 +122,16 @@ update-po:
            fi; \
          done
+lint: $(DATA_FILES) $(SCHEMA_FILES)
+	@command -v $(PYTHON) > /dev/null; \
+	if [ $$? -ne 0 ] ; then \
+	  for xml in `find data -name '*.xml' | sort`; do \
+	    if ! $(XMLLINT) --relaxng data/schema/osinfo.rng --noout $$xml; then \
+	      exit 1; \
+	    fi; \
+	  done \
+	fi
+
  unit-tests: $(DATA_FILES) $(SCHEMA_FILES)
  	@command -v $(PYTHON) > /dev/null; \
  	if [ $$? -eq 0 ] ; then \
@@ -131,4 +143,4 @@ unit-tests: $(DATA_FILES) $(SCHEMA_FILES)
  	  echo "unit-tests are not going to be executed as no $(PYTHON) has been found"; \
  	fi
-check: unit-tests
+check: lint unit-tests


If this is just to appease rhel7/centos7 CI, I'd rather either;

- make the tests work on python2
- have CI pull down python3 packages from EPEL
- just not run the tests on centos7

On the code side, making the tests work on python2 is as simple as:

diff --git a/tests/osinfo.py b/tests/osinfo.py
index eb63724..02c8f7e 100644
--- a/tests/osinfo.py
+++ b/tests/osinfo.py
@@ -1,9 +1,13 @@
 # This work is licensed under the GNU GPLv2 or later.
 # See the COPYING file in the top-level directory.

-from http.client import responses
-import logging
 import re
+import sys
+
+if sys.version_info[0] > 3:
+    from http.client import responses
+else:
+    from httplib import responses

 import requests


However 'make check' isn't going to 'just work' in this case, because it needs to differentiate using py.test (on centos7) vs pytest-3. And CI will need to pull down all the python2 deps: python-requests, libxml2-python, python-pytest. I also didn't test the network tests, there might be issues lurking there.

I don't have a strong opinion one way or the other if it's worth it. But re-adding this bit which will double run xml validation and drown out the pytest results with the xmllint spam is not nice IMO

- Cole


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]