]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Load env vars in shell-only processing of conf.sh
authorTom Krizek <tkrizek@isc.org>
Thu, 29 Feb 2024 13:49:38 +0000 (14:49 +0100)
committerNicki Křížek <nicki@isc.org>
Thu, 9 May 2024 15:08:09 +0000 (17:08 +0200)
While this isn't required for pytest operation and execution of the
system test suite, it can be handy to allow test script development and
debugging. Especially setup scripts often source conf.sh and expect
environment variables to be loaded. If these scripts are executed
stand-alone, the environment variables need to be loaded from the python
package.

bin/tests/system/conf.sh
bin/tests/system/isctest/__main__.py [new file with mode: 0644]

index 131c72dbbb59bd4f232a3afeb029b22581ac6ed0..ec65c6f412f68eba7b981c74d56ce6b18723a214 100644 (file)
 # See the COPYRIGHT file distributed with this work for additional
 # information regarding copyright ownership.
 
+# When sourcing the script outside the pytest environment (e.g. during helper
+# script development), the env variables have to be loaded.
+if [ -z "$TOP_SRCDIR" ]; then
+    SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd | sed -E 's|(.*bin/tests/system).*|\1|')
+    eval "$(PYTHONPATH="$SCRIPT_DIR:$PYTHONPATH" /usr/bin/env python3 -m isctest)"
+fi
+
 testsock6() {
        if test -n "$PERL" && $PERL -e "use IO::Socket::IP;" 2> /dev/null
        then
diff --git a/bin/tests/system/isctest/__main__.py b/bin/tests/system/isctest/__main__.py
new file mode 100644 (file)
index 0000000..2b82a81
--- /dev/null
@@ -0,0 +1,17 @@
+# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+#
+# SPDX-License-Identifier: MPL-2.0
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0.  If a copy of the MPL was not distributed with this
+# file, you can obtain one at https://mozilla.org/MPL/2.0/.
+#
+# See the COPYRIGHT file distributed with this work for additional
+# information regarding copyright ownership.
+
+from .vars import ALL
+
+
+if __name__ == "__main__":
+    for name, value in ALL.items():
+        print(f"export {name}={value}")