Files
bind9/bin/tests/system/isctest/vars/build.py
Nicki Křížek 1c72708c30 Pytest integration for meson build
Integrate the system test runner to work with meson build system. On
each compilation, create build-dependent variables in
isctest/vars/.build_env. Then, run a custom script (on every single
rebuild) to put TOP_BUILDDIR into the source directory (as well as
ifconfig.sh for developer convenience).

When pytest is executed, it always reads TOP_BUILDDIR variable from the
source directory where it was placed by the previously. Then it knows
which directory to use to read the remaining build variables and
proceeds as usual.

meson test command was considered for running system tests, but
ultimately it seems that running pytest directly (from source dir as
devs are used to) is a better solution. Some of the issues with meson
test include: different test granularity from `pytest`, having to
maintain extra list of tests, incorrect reporting of skipped tests, no
advance usage (e.g. using pytest's options) and maintaining two slightly
different ways of running system tests.
2024-11-29 17:42:55 +01:00

64 lines
1.6 KiB
Python

# 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 pathlib import Path
import os
from typing import Dict
SYSTEM_TEST_DIR_GIT_PATH = "bin/tests/system"
def read_var_from_build_file(path) -> str:
if not path.exists():
raise RuntimeError(
f'Uninitialized build variable: "{path}". Did you run `meson compile`?'
)
return path.read_text(encoding="utf-8").strip()
def load_vars_from_build_files() -> Dict[str, str]:
# TOP_BUILDDIR is special, it is always read from the source directory
top_builddir_file = Path(__file__).resolve().parent / ".build_vars" / "TOP_BUILDDIR"
top_builddir = read_var_from_build_file(top_builddir_file)
build_vars = {
"TOP_BUILDDIR": top_builddir,
}
var_targets = [
"SHELL",
"PERL",
"XSLTPROC",
"CURL",
"NC",
"TOP_SRCDIR",
"FSTRM_CAPTURE",
"PYTEST",
"PYTHON",
]
var_dir = (
Path(top_builddir)
/ SYSTEM_TEST_DIR_GIT_PATH
/ "isctest"
/ "vars"
/ ".build_vars"
)
for var in var_targets:
var_file = var_dir / var
var_value = read_var_from_build_file(var_file)
build_vars[var] = var_value
return build_vars
BUILD_VARS = load_vars_from_build_files()