]> 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 10:05:46 +0000 (11:05 +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.

(cherry picked from commit 9730ac4c5691c36d58c06deec1762a4831b268c5)

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

index b9641c42b2d91fd65b79f00ca8820f40bc1d2e9d..cd1f1078b09e528466a77c7d780cbca96a93c716 100644 (file)
@@ -123,15 +123,4 @@ PYTEST=@PYTEST@
 #
 # Determine if we support various optional features.
 #
-LIBXML2_LIBS="@LIBXML2_LIBS@"
-HAVEXMLSTATS=${LIBXML2_LIBS:+1}
-JSON_C_LIBS="@JSON_C_LIBS@"
-HAVEJSONSTATS=${JSON_C_LIBS:+1}
-MAXMINDDB_LIBS="@MAXMINDDB_LIBS@"
-HAVEGEOIP2=${MAXMINDDB_LIBS:+1}
-ZLIB_LIBS="@ZLIB_LIBS@"
-HAVEZLIB=${ZLIB_LIBS:+1}
-NZD=@NZD_TOOLS@
 CRYPTO=@CRYPTO@
-
-export HAVEXMLSTATS HAVEJSONSTATS
index 86a3be3aa856d200048be7e34745a1563d925f39..2915f61b7408cbc4a0eb8fba79ac966a392c5c72 100644 (file)
@@ -119,10 +119,6 @@ PYTHON=@PYTHON@
 #
 # Determine if we support various optional features.
 #
-HAVEXMLSTATS=@XMLSTATS@
-HAVEJSONSTATS=@JSONSTATS@
-HAVEZLIB=@ZLIB@
-NZD=@NZD_TOOLS@
 CRYPTO=@CRYPTO@
 
 # The rest is shared between Windows and Unices
index 7fe5a050ea3661a8f5cc39f5fe00f2483808fb7f..5498945d9f0d6d88f59be22a674191dd87e45998 100644 (file)
@@ -12,7 +12,7 @@
 SYSTEMTESTTOP=..
 . $SYSTEMTESTTOP/conf.sh
 
-if [ -z "$NZD" ]; then
+if ! $FEATURETEST --with-lmdb; then
         echo_i "This test requires LMDB support (--with-lmdb)"
         exit 255
 fi
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")