mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-23 10:42:11 +01:00
Merge branch 'wip/smcv/girxml-search-path' into 'main'
tests: Search the appropriate directories for our GIR XML inputs See merge request GNOME/glib!4509
This commit is contained in:
commit
97bd09a04f
@ -1175,6 +1175,7 @@ endforeach
|
|||||||
|
|
||||||
python_test_env = test_env
|
python_test_env = test_env
|
||||||
python_test_env.prepend('PYTHONPATH', python_test_libraries_path)
|
python_test_env.prepend('PYTHONPATH', python_test_libraries_path)
|
||||||
|
python_test_env.prepend('PYTHONPATH', python_test_libraries_built)
|
||||||
|
|
||||||
foreach test_name, extra_args : python_tests
|
foreach test_name, extra_args : python_tests
|
||||||
depends = [extra_args.get('depends', [])]
|
depends = [extra_args.get('depends', [])]
|
||||||
|
@ -303,6 +303,8 @@ static GMarkupParser firstpass_parser =
|
|||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* If you change this search order, gobject-introspection.git and
|
||||||
|
* tests/installed/glibconfig.py.in will probably also need updating */
|
||||||
static char *
|
static char *
|
||||||
locate_gir (GIIrParser *parser,
|
locate_gir (GIIrParser *parser,
|
||||||
const char *girname)
|
const char *girname)
|
||||||
|
@ -29,7 +29,10 @@ else
|
|||||||
gir_dir_pc_prefix = join_paths('${prefix}', gir_dir_prefix)
|
gir_dir_pc_prefix = join_paths('${prefix}', gir_dir_prefix)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
glib_girdir = get_option('prefix') / gir_dir_prefix / 'gir-1.0'
|
# This is effectively the GIR XML format major version
|
||||||
|
gir_suffix = 'gir-1.0'
|
||||||
|
|
||||||
|
glib_girdir = get_option('prefix') / gir_dir_prefix / gir_suffix
|
||||||
|
|
||||||
gir_includedir = glib_includedir / 'girepository'
|
gir_includedir = glib_includedir / 'girepository'
|
||||||
|
|
||||||
@ -81,7 +84,7 @@ install_headers(girepo_headers + girepo_ffi_headers, install_dir: gir_includedir
|
|||||||
gir_c_args = [
|
gir_c_args = [
|
||||||
'-DGI_COMPILATION',
|
'-DGI_COMPILATION',
|
||||||
'-DG_LOG_DOMAIN="GLib-GIRepository"',
|
'-DG_LOG_DOMAIN="GLib-GIRepository"',
|
||||||
'-DGIR_SUFFIX="gir-1.0"',
|
'-DGIR_SUFFIX="@0@"'.format(gir_suffix),
|
||||||
'-DGIR_DIR="@0@"'.format(glib_girdir),
|
'-DGIR_DIR="@0@"'.format(glib_girdir),
|
||||||
'-DGOBJECT_INTROSPECTION_LIBDIR="@0@"'.format(glib_libdir),
|
'-DGOBJECT_INTROSPECTION_LIBDIR="@0@"'.format(glib_libdir),
|
||||||
'-DGOBJECT_INTROSPECTION_DATADIR="@0@"'.format(glib_datadir),
|
'-DGOBJECT_INTROSPECTION_DATADIR="@0@"'.format(glib_datadir),
|
||||||
@ -227,7 +230,7 @@ executable('gi-dump-types',
|
|||||||
|
|
||||||
pkgconfig_variables = [
|
pkgconfig_variables = [
|
||||||
'gidatadir=${datadir}/gobject-introspection-1.0',
|
'gidatadir=${datadir}/gobject-introspection-1.0',
|
||||||
'girdir=' + gir_dir_pc_prefix / 'gir-1.0',
|
'girdir=' + gir_dir_pc_prefix / gir_suffix,
|
||||||
'typelibdir=${libdir}/girepository-1.0',
|
'typelibdir=${libdir}/girepository-1.0',
|
||||||
'gi_compile_repository=' + pkgconfig_multiarch_bindir / 'gi-compile-repository'
|
'gi_compile_repository=' + pkgconfig_multiarch_bindir / 'gi-compile-repository'
|
||||||
]
|
]
|
||||||
|
@ -20,11 +20,12 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
# MA 02110-1301 USA
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
""" Integration tests for gi-compile-repository. """
|
"""Integration tests for gi-compile-repository."""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
import glibconfig
|
||||||
import taptestrunner
|
import taptestrunner
|
||||||
import testprogramrunner
|
import testprogramrunner
|
||||||
|
|
||||||
@ -39,20 +40,9 @@ class TestGICompileRepositoryBase(testprogramrunner.TestProgramRunner):
|
|||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
super().setUpClass()
|
super().setUpClass()
|
||||||
|
|
||||||
if "G_TEST_BUILDDIR" in os.environ:
|
# list of pathlib.Path
|
||||||
cls._gir_path = os.path.join(
|
cls._gir_paths = glibconfig.GIR_XML_SEARCH_PATHS
|
||||||
os.environ["G_TEST_BUILDDIR"], "..", "introspection"
|
print(f"gir path set to {cls._gir_paths}")
|
||||||
)
|
|
||||||
else:
|
|
||||||
cls._gir_path = os.path.join(
|
|
||||||
os.path.dirname(os.path.realpath(__file__)),
|
|
||||||
"..",
|
|
||||||
"..",
|
|
||||||
"..",
|
|
||||||
"share",
|
|
||||||
"gir-1.0",
|
|
||||||
)
|
|
||||||
print(f"gir path set to {cls._gir_path}")
|
|
||||||
|
|
||||||
|
|
||||||
class TestGICompileRepository(TestGICompileRepositoryBase):
|
class TestGICompileRepository(TestGICompileRepositoryBase):
|
||||||
@ -73,13 +63,20 @@ class TestGICompileRepositoryForGLib(TestGICompileRepositoryBase):
|
|||||||
GIR_NAME = "GLib-2.0"
|
GIR_NAME = "GLib-2.0"
|
||||||
|
|
||||||
def runTestProgram(self, *args, **kwargs):
|
def runTestProgram(self, *args, **kwargs):
|
||||||
gir_file = os.path.join(self._gir_path, f"{self.GIR_NAME}.gir")
|
for d in self._gir_paths:
|
||||||
self.assertTrue(os.path.exists(gir_file))
|
gir_file = d / f"{self.GIR_NAME}.gir"
|
||||||
argv = [gir_file]
|
|
||||||
|
if gir_file.exists():
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
self.fail(f"Could not find {self.GIR_NAME}.gir in {self._gir_paths}")
|
||||||
|
|
||||||
|
argv = [str(gir_file)]
|
||||||
argv.extend(*args)
|
argv.extend(*args)
|
||||||
|
|
||||||
if self.GIR_NAME != "GLib-2.0":
|
if self.GIR_NAME != "GLib-2.0":
|
||||||
argv.extend(["--includedir", self._gir_path])
|
for d in self._gir_paths:
|
||||||
|
argv.extend(["--includedir", str(d)])
|
||||||
|
|
||||||
return super().runTestProgram(argv, **kwargs)
|
return super().runTestProgram(argv, **kwargs)
|
||||||
|
|
||||||
|
@ -183,6 +183,7 @@ endif
|
|||||||
|
|
||||||
python_test_env = test_env
|
python_test_env = test_env
|
||||||
python_test_env.prepend('PYTHONPATH', python_test_libraries_path)
|
python_test_env.prepend('PYTHONPATH', python_test_libraries_path)
|
||||||
|
python_test_env.prepend('PYTHONPATH', python_test_libraries_built)
|
||||||
|
|
||||||
foreach test_name, extra_args : python_tests
|
foreach test_name, extra_args : python_tests
|
||||||
depends = [extra_args.get('depends', [])]
|
depends = [extra_args.get('depends', [])]
|
||||||
|
@ -514,6 +514,7 @@ endif
|
|||||||
|
|
||||||
python_test_env = test_env
|
python_test_env = test_env
|
||||||
python_test_env.prepend('PYTHONPATH', python_test_libraries_path)
|
python_test_env.prepend('PYTHONPATH', python_test_libraries_path)
|
||||||
|
python_test_env.prepend('PYTHONPATH', python_test_libraries_built)
|
||||||
|
|
||||||
foreach test_name, extra_args : python_tests
|
foreach test_name, extra_args : python_tests
|
||||||
depends = [extra_args.get('depends', [])]
|
depends = [extra_args.get('depends', [])]
|
||||||
|
@ -234,6 +234,7 @@ endforeach
|
|||||||
|
|
||||||
python_test_env = test_env
|
python_test_env = test_env
|
||||||
python_test_env.prepend('PYTHONPATH', python_test_libraries_path)
|
python_test_env.prepend('PYTHONPATH', python_test_libraries_path)
|
||||||
|
python_test_env.prepend('PYTHONPATH', python_test_libraries_built)
|
||||||
|
|
||||||
foreach test_name, extra_args : python_tests
|
foreach test_name, extra_args : python_tests
|
||||||
depends = [extra_args.get('depends', [])]
|
depends = [extra_args.get('depends', [])]
|
||||||
|
@ -2500,6 +2500,7 @@ assert(fs.exists(python_test_libraries_path))
|
|||||||
if not python_version.version_compare(python_version_req)
|
if not python_version.version_compare(python_version_req)
|
||||||
error('Requires Python @0@, @1@ found.'.format(python_version_req, python_version))
|
error('Requires Python @0@, @1@ found.'.format(python_version_req, python_version))
|
||||||
endif
|
endif
|
||||||
|
python_test_libraries_built = meson.project_build_root() / 'tests' / 'lib'
|
||||||
|
|
||||||
# Determine which user environment-dependent files that we want to install
|
# Determine which user environment-dependent files that we want to install
|
||||||
bash = find_program('bash', required : false)
|
bash = find_program('bash', required : false)
|
||||||
|
@ -16,7 +16,7 @@ export TEST_REQUIRES_TOOLS="black git"
|
|||||||
|
|
||||||
run_lint () {
|
run_lint () {
|
||||||
# shellcheck disable=SC2046
|
# 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
|
# shellcheck source=tests/lint-common.sh
|
||||||
|
@ -21,7 +21,7 @@ run_lint () {
|
|||||||
# shellcheck disable=SC2046
|
# shellcheck disable=SC2046
|
||||||
flake8 \
|
flake8 \
|
||||||
--max-line-length=88 --ignore="$formatting_warnings" \
|
--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
|
# 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@") / r"@gir_suffix@",
|
||||||
|
]
|
26
tests/lib/meson.build
Normal file
26
tests/lib/meson.build
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# 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('gir_suffix', gir_suffix)
|
||||||
|
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',
|
protocol : 'tap',
|
||||||
)
|
)
|
||||||
|
|
||||||
# TAP test runner for Python tests
|
subdir('lib')
|
||||||
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
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user