]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Use feature-test feature detection in pytests
authorTom Krizek <tkrizek@isc.org>
Thu, 1 Dec 2022 14:21:22 +0000 (15:21 +0100)
committerTom Krizek <tkrizek@isc.org>
Fri, 2 Dec 2022 09:23:52 +0000 (10:23 +0100)
Avoid using the environment variables for feature detection and use the
feature-test utility instead.

Remove the obsolete environment variables from conf.sh, since they're no
longer used anywhere.

bin/tests/system/conf.sh.in
bin/tests/system/pytest_custom_markers.py
bin/tests/system/statschannel/tests-json.py
bin/tests/system/statschannel/tests-xml.py

index a41ac10b631acf1e2599a7b2245941dc7fa9d68c..d6c76ea6f1290f6ce8ec8c831d0759647da59d3d 100644 (file)
@@ -113,18 +113,3 @@ export PERL=$(command -v "@PERL@")
 
 export PYTHON=$(command -v "@PYTHON@" || true)
 export PYTEST=@PYTEST@
-
-#
-# Determine if we support various optional features.
-#
-export LIBXML2_LIBS="@LIBXML2_LIBS@"
-export HAVEXMLSTATS=${LIBXML2_LIBS:+1}
-export JSON_C_LIBS="@JSON_C_LIBS@"
-export HAVEJSONSTATS=${JSON_C_LIBS:+1}
-export MAXMINDDB_LIBS="@MAXMINDDB_LIBS@"
-export HAVEGEOIP2=${MAXMINDDB_LIBS:+1}
-export ZLIB_LIBS="@ZLIB_LIBS@"
-export HAVEZLIB=${ZLIB_LIBS:+1}
-export LMDB_LIBS="@LMDB_LIBS@"
-export NZD=${LMDB_LIBS:+1}
-export CRYPTO=@CRYPTO@
index 55b02f6c58a0d6a830741c78ca7669e4cb22a9a1..9714c0fbf5ae1f206c7138b19d621fdba039fc6c 100644 (file)
@@ -12,6 +12,7 @@
 # information regarding copyright ownership.
 
 import os
+import subprocess
 
 import pytest
 
@@ -19,3 +20,23 @@ import pytest
 long_test = pytest.mark.skipif(
     not os.environ.get("CI_ENABLE_ALL_TESTS"), reason="CI_ENABLE_ALL_TESTS not set"
 )
+
+
+def feature_test(feature):
+    feature_test_bin = os.environ["FEATURETEST"]
+    try:
+        subprocess.run([feature_test_bin, feature], check=True)
+    except subprocess.CalledProcessError as exc:
+        if exc.returncode != 1:
+            raise
+        return False
+    return True
+
+
+have_libxml2 = pytest.mark.skipif(
+    feature_test("--have-libxml2"), reason="libxml2 support disabled in the build"
+)
+
+have_json_c = pytest.mark.skipif(
+    feature_test("--have-json-c"), reason="json-c support disabled in the build"
+)
index d94a32f7da23c63271f956652cb5ebffb37c8fbb..312c6830a6bd6176b4e9a4b0fd09b47d84e7f46a 100755 (executable)
 
 from datetime import datetime
 
-import os
-
 import pytest
 
 import generic
+import pytest_custom_markers
 
-pytestmark = pytest.mark.skipif(
-    not os.environ.get("HAVEJSONSTATS"), reason="json-c support disabled in the build"
-)
+pytestmark = pytest_custom_markers.have_json_c
 requests = pytest.importorskip("requests")
 
 
index 423754916ab964b7ee82f9db6ef68bbe048e3944..5b187b0f49f8888417d6aab9f59676ba711a46fb 100755 (executable)
 # See the COPYRIGHT file distributed with this work for additional
 # information regarding copyright ownership.
 
-import xml.etree.ElementTree as ET
 from datetime import datetime
-
-import os
+import xml.etree.ElementTree as ET
 
 import pytest
 
 import generic
+import pytest_custom_markers
 
-pytestmark = pytest.mark.skipif(
-    not os.environ.get("HAVEXMLSTATS"), reason="libxml2 support disabled in the build"
-)
+pytestmark = pytest_custom_markers.have_libxml2
 requests = pytest.importorskip("requests")