mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-02 07:23:41 +02:00
tests: Search the appropriate directories for our GIR XML inputs
During "as-installed" testing, we should search the GIR_DIR for GIR XML, instead of hard-coding that it is `${prefix}/share/gir-1.0`. This is not the case on at least Debian, in order to make it possible to install more than one architecture's flavour of `GLib-2.0.gir`, which contains some architecture-specific `#define`s. Also search GOBJECT_INTROSPECTION_DATADIR/GIR_SUFFIX (in practice something like `/usr/share/gir-1.0` in all cases) to accommodate distributions like Debian that move the architecture-independent majority of GIR XML into /usr/share to avoid duplication, leaving only the architecture-specific minority of files like `GLib-2.0.gir` in the GIR_DIR. Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
@@ -16,7 +16,7 @@ export TEST_REQUIRES_TOOLS="black git"
|
||||
|
||||
run_lint () {
|
||||
# shellcheck disable=SC2046
|
||||
black --diff --check $(git ls-files '*.py')
|
||||
black --diff --check $(git ls-files '*.py' 'tests/lib/*.py.in')
|
||||
}
|
||||
|
||||
# shellcheck source=tests/lint-common.sh
|
||||
|
@@ -21,7 +21,7 @@ run_lint () {
|
||||
# shellcheck disable=SC2046
|
||||
flake8 \
|
||||
--max-line-length=88 --ignore="$formatting_warnings" \
|
||||
$(git ls-files '*.py')
|
||||
$(git ls-files '*.py' 'tests/lib/*.py.in')
|
||||
}
|
||||
|
||||
# shellcheck source=tests/lint-common.sh
|
||||
|
29
tests/lib/glibconfig.py.in
Normal file
29
tests/lib/glibconfig.py.in
Normal file
@@ -0,0 +1,29 @@
|
||||
# Copyright 2025 Simon McVittie
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
if "G_TEST_BUILDDIR" in os.environ:
|
||||
# During build-time testing, we search the build tree.
|
||||
# We can't use the value of G_TEST_BUILDDIR here because we don't
|
||||
# know how deeply nested the current build directory is.
|
||||
project_build_root = Path(__file__).resolve().parent.parent.parent
|
||||
|
||||
# Where to find GLib-2.0.gir, etc. as a list of Path, highest priority first
|
||||
GIR_XML_SEARCH_PATHS = [
|
||||
project_build_root / "girepository" / "introspection",
|
||||
]
|
||||
|
||||
else:
|
||||
# During as-installed testing, we search the final paths.
|
||||
|
||||
# This is a subset of the search path from girparser.c locate_gir(),
|
||||
# with only the directories that are part of GLib's prefix,
|
||||
# excluding XDG_DATA_HOME, XDG_DATA_DIRS and the hard-coded
|
||||
# /usr/share fallback
|
||||
GIR_XML_SEARCH_PATHS = [
|
||||
Path(r"@glib_girdir@"),
|
||||
Path(r"@glib_datadir@") / "gir-1.0",
|
||||
]
|
25
tests/lib/meson.build
Normal file
25
tests/lib/meson.build
Normal file
@@ -0,0 +1,25 @@
|
||||
# Copyright 2024 Collabora Ltd.
|
||||
# Copyright 2025 Simon McVittie
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
install_data(
|
||||
files(
|
||||
'taptestrunner.py',
|
||||
'testprogramrunner.py',
|
||||
),
|
||||
install_dir: installed_tests_execdir,
|
||||
install_tag: 'tests',
|
||||
)
|
||||
|
||||
tests_conf = configuration_data()
|
||||
tests_conf.set('glib_datadir', glib_datadir)
|
||||
tests_conf.set('glib_girdir', glib_girdir)
|
||||
|
||||
configure_file(
|
||||
configuration: tests_conf,
|
||||
input: 'glibconfig.py.in',
|
||||
output: 'glibconfig.py',
|
||||
install: installed_tests_enabled,
|
||||
install_dir: installed_tests_execdir,
|
||||
install_tag: 'tests',
|
||||
)
|
@@ -34,18 +34,4 @@ test(
|
||||
protocol : 'tap',
|
||||
)
|
||||
|
||||
# TAP test runner for Python tests
|
||||
if installed_tests_enabled
|
||||
lib_path = fs.relative_to(
|
||||
meson.project_source_root() / python_test_libraries_path,
|
||||
meson.current_source_dir())
|
||||
|
||||
install_data(
|
||||
files(
|
||||
lib_path / 'taptestrunner.py',
|
||||
lib_path / 'testprogramrunner.py',
|
||||
),
|
||||
install_dir: installed_tests_execdir,
|
||||
install_tag: 'tests',
|
||||
)
|
||||
endif
|
||||
subdir('lib')
|
||||
|
Reference in New Issue
Block a user