Move dir env var handling to isctest.vars.dirs

This commit is contained in:
Tom Krizek 2024-02-28 16:49:22 +01:00 committed by Nicki Křížek
parent 41cb553bdd
commit 1f6f2234d8
No known key found for this signature in database
GPG key ID: 01623B9B652A20A7
7 changed files with 36 additions and 15 deletions

View file

@ -24,6 +24,7 @@ import pytest
pytest.register_assert_rewrite("isctest")
import isctest
from isctest.vars.dirs import SYSTEM_TEST_DIR_GIT_PATH
# Silence warnings caused by passing a pytest fixture to another fixture.
@ -61,7 +62,6 @@ PRIORITY_TESTS = [
"upforwd/",
]
PRIORITY_TESTS_RE = re.compile("|".join(PRIORITY_TESTS))
SYSTEM_TEST_DIR_GIT_PATH = "bin/tests/system"
SYSTEM_TEST_NAME_RE = re.compile(f"{SYSTEM_TEST_DIR_GIT_PATH}" + r"/([^/]+)")
SYMLINK_REPLACEMENT_RE = re.compile(r"/tests(_.*)\.py")
@ -260,8 +260,6 @@ def control_port():
def env():
"""Dictionary containing environment variables for the test."""
env = dict(isctest.vars.ALL)
env["builddir"] = f"{env['TOP_BUILDDIR']}/{SYSTEM_TEST_DIR_GIT_PATH}"
env["srcdir"] = f"{env['TOP_SRCDIR']}/{SYSTEM_TEST_DIR_GIT_PATH}"
os.environ.update(env)
return env
@ -354,14 +352,13 @@ def system_test_dir(
pass
# Create a temporary directory with a copy of the original system test dir contents
system_test_root = Path(
f"{isctest.vars.ALL['TOP_BUILDDIR']}/{SYSTEM_TEST_DIR_GIT_PATH}"
)
system_test_root = Path(os.environ["builddir"])
testdir = Path(
tempfile.mkdtemp(prefix=f"{system_test_name}_tmp_", dir=system_test_root)
)
shutil.rmtree(testdir)
shutil.copytree(system_test_root / system_test_name, testdir)
isctest.vars.dirs.set_system_test_name(testdir.name)
# Create a convenience symlink with a stable and predictable name
module_name = SYMLINK_REPLACEMENT_RE.sub(r"\1", request.node.name)

View file

@ -16,6 +16,7 @@ from .autoconf import AC_VARS # type: ignore
# pylint: enable=import-error
from .basic import BASIC_VARS
from .dirs import DIR_VARS
from .openssl import OPENSSL_VARS
from .ports import PORT_VARS
@ -51,4 +52,4 @@ class VarLookup(ChainMap):
return iter(self.keys())
ALL = VarLookup(AC_VARS, BASIC_VARS, OPENSSL_VARS, PORT_VARS)
ALL = VarLookup(AC_VARS, BASIC_VARS, OPENSSL_VARS, PORT_VARS, DIR_VARS)

View file

@ -0,0 +1,31 @@
# 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.
import os
# pylint: disable=import-error
from .autoconf import AC_VARS # type: ignore
# pylint: enable=import-error
SYSTEM_TEST_DIR_GIT_PATH = "bin/tests/system"
DIR_VARS = {
"builddir": f"{AC_VARS['TOP_BUILDDIR']}/{SYSTEM_TEST_DIR_GIT_PATH}",
"srcdir": f"{AC_VARS['TOP_SRCDIR']}/{SYSTEM_TEST_DIR_GIT_PATH}",
"SYSTESTDIR": None,
}
def set_system_test_name(name: str):
DIR_VARS["SYSTESTDIR"] = name
os.environ["SYSTESTDIR"] = name

View file

@ -13,8 +13,6 @@
. ../../conf.sh
SYSTESTDIR=legacy
echo_i "sign edns512"
zone=edns512

View file

@ -13,8 +13,6 @@
. ../../conf.sh
SYSTESTDIR=legacy
echo_i "sign edns512-notcp"
zone=edns512-notcp

View file

@ -13,8 +13,6 @@
. ../../conf.sh
SYSTESTDIR=verify
dumpit() {
echo_d "${debug}: dumping ${1}"
cat "${1}" | cat_d

View file

@ -13,8 +13,6 @@
. ../../conf.sh
SYSTESTDIR=wildcard
dssets=
# RFC 4592 example zone.