meson: Add tests for generated pkg-config files

Ensure things are generated as we expect and avoid we regress on that.
This commit is contained in:
Marco Trevisan (Treviño) 2023-04-14 19:56:32 +02:00
parent fcad56e313
commit ade79bcb50
5 changed files with 149 additions and 1 deletions

View File

@ -1096,4 +1096,72 @@ if installed_tests_enabled
) )
endif endif
if have_bash and have_pkg_config
prefix = get_option('prefix')
if prefix.endswith(':/')
prefix += '/'
endif
pkg_config_tests = [
'pkg-config --validate gio-2.0',
'test "$(pkg-config --modversion gio-2.0)" = "@0@"'.format(glib_version),
'test "$(pkg-config --variable=prefix gio-2.0)" = "@0@"'.format(
get_option('prefix')),
'test "$(pkg-config --variable=datadir gio-2.0)" = "@0@"'.format(
prefix / get_option('datadir')),
'test "$(pkg-config --variable=schemasdir gio-2.0)" = "@0@"'.format(
prefix / get_option('datadir') / schemas_subdir),
'test "$(pkg-config --variable=giomoduledir gio-2.0)" = "@0@"'.format(
get_option('gio_module_dir') != '' ?
prefix / get_option('gio_module_dir') :
prefix / get_option('libdir') / 'gio' / 'modules'),
]
gio_binaries = [
'gio',
'gio-querymodules',
'glib-compile-schemas',
'glib-compile-resources',
'gdbus',
'gdbus-codegen',
'gresource',
'gsettings',
]
foreach binary: gio_binaries
pkg_config_tests += [
'test "$(pkg-config --variable=@0@ gio-2.0)" = "@1@"'.format(
binary.underscorify(),
prefix / get_option('bindir') / binary)
]
endforeach
test('gio-2.0-pkg-config',
bash,
args: [ '-xe', '-c', '\n'.join(pkg_config_tests) ],
suite: ['gio', 'no-valgrind', 'pkg-config'],
env: {
'PKG_CONFIG_PATH': meson.project_build_root() / 'meson-private',
},
)
platform_module = host_system == 'windows' ? 'gio-windows-2.0' : 'gio-unix-2.0'
pkg_config_tests = [
'pkg-config --validate ' + platform_module,
'test "$(pkg-config --modversion @0@)" = "@1@"'.format(platform_module,
glib_version),
'test "$(pkg-config --variable=prefix @0@)" = "@1@"'.format(platform_module,
get_option('prefix')),
]
test(platform_module + '-pkg-config',
bash,
args: [ '-xe', '-c', '\n'.join(pkg_config_tests) ],
suite: ['gio', 'no-valgrind', 'pkg-config'],
env: {
'PKG_CONFIG_PATH': meson.project_build_root() / 'meson-private',
},
)
endif
subdir('services') subdir('services')

View File

@ -490,3 +490,34 @@ if not meson.is_cross_build() and host_system != 'windows'
endif endif
endif endif
if have_bash and have_pkg_config
prefix = get_option('prefix')
if prefix.endswith(':/')
prefix += '/'
endif
test('glib-2.0-pkg-config',
bash,
args: [
'-xe', '-c',
'\n'.join([
'pkg-config --validate glib-2.0',
'test "$(pkg-config --modversion glib-2.0)" = "@0@"'.format(glib_version),
'test "$(pkg-config --variable=prefix glib-2.0)" = "@0@"'.format(
get_option('prefix')),
'test "$(pkg-config --variable=datadir glib-2.0)" = "@0@"'.format(
prefix / get_option('datadir')),
'test "$(pkg-config --variable=gobject_query glib-2.0)" = "@0@"'.format(
prefix / get_option('bindir') / 'gobject-query'),
'test "$(pkg-config --variable=glib_mkenums glib-2.0)" = "@0@"'.format(
prefix / get_option('bindir') / 'glib-mkenums'),
'test "$(pkg-config --variable=glib_valgrind_suppressions glib-2.0)" = "@0@"'.format(
prefix / get_option('datadir') /
valgrind_suppression_file_install_subdir / fs.name(valgrind_suppression_file)),
]),
],
suite: ['glib', 'core', 'no-valgrind', 'pkg-config'],
env: {
'PKG_CONFIG_PATH': meson.project_build_root() / 'meson-private',
},
)
endif

View File

@ -124,3 +124,31 @@ foreach test_name, extra_args : gmodule_tests
suite : suite, suite : suite,
) )
endforeach endforeach
if have_bash and have_pkg_config
modules = [
'gmodule-no-export-2.0',
'gmodule-export-2.0',
'gmodule-2.0',
]
foreach module: modules
test(module + '-pkg-config',
bash,
args: [
'-xe', '-c',
'\n'.join([
'pkg-config --validate ' + module,
'test "$(pkg-config --modversion @0@)" = "@1@"'.format(
module, glib_version),
'test "$(pkg-config --variable=prefix @0@)" = "@1@"'.format(
module, get_option('prefix')),
]),
],
suite: ['gmodule', 'no-valgrind', 'pkg-config'],
env: {
'PKG_CONFIG_PATH': meson.project_build_root() / 'meson-private',
},
)
endforeach
endif

View File

@ -52,3 +52,22 @@ foreach test_name, extra_args : gthread_tests
suite : suite, suite : suite,
) )
endforeach endforeach
if have_bash and have_pkg_config
test('gthread-2.0-pkg-config',
bash,
args: [
'-xe', '-c',
'\n'.join([
'pkg-config --validate gthread-2.0',
'test "$(pkg-config --modversion gthread-2.0)" = "@0@"'.format(glib_version),
'test "$(pkg-config --variable=prefix gthread-2.0)" = "@0@"'.format(
get_option('prefix')),
]),
],
suite: ['gthread', 'no-valgrind', 'pkg-config'],
env: {
'PKG_CONFIG_PATH': meson.project_build_root() / 'meson-private',
},
)
endif

View File

@ -2287,9 +2287,11 @@ if not python_version.version_compare(python_version_req)
endif endif
# Determine which user environment-dependent files that we want to install # Determine which user environment-dependent files that we want to install
have_bash = find_program('bash', required : false).found() # For completion scripts bash = find_program('bash', required : false)
have_bash = bash.found() # For completion scripts
bash_comp_dep = dependency('bash-completion', version: '>=2.0', required: false) bash_comp_dep = dependency('bash-completion', version: '>=2.0', required: false)
have_sh = find_program('sh', required : false).found() # For glib-gettextize have_sh = find_program('sh', required : false).found() # For glib-gettextize
have_pkg_config = find_program('pkg-config', required: false).found()
# Some installed tests require a custom environment # Some installed tests require a custom environment
env_program = find_program('env', required: installed_tests_enabled) env_program = find_program('env', required: installed_tests_enabled)