From c5665d3e6547e21d57564abbbfcb01705e0a7744 Mon Sep 17 00:00:00 2001 From: Benjamin Berg Date: Tue, 10 Apr 2018 18:19:05 +0200 Subject: data: Compile gschema files at build time and copy into tests Without this we need to install the GSchema files for testing purposes. --- data/meson.build | 16 +++++++++++++--- tests/gsdtestcase.py | 5 +++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/data/meson.build b/data/meson.build index 5c4fb507..e93ba641 100644 --- a/data/meson.build +++ b/data/meson.build @@ -15,19 +15,20 @@ schemas = [ schema_conf = configuration_data() schema_conf.set('GETTEXT_PACKAGE', meson.project_name()) +schemas_xml = [] foreach schema: schemas - configure_file( + schemas_xml += [configure_file( input: schema + '.in', output: schema, configuration: schema_conf, install: true, install_dir: gsd_schemadir - ) + )] endforeach enums_header = files('gsd-enums.h') -gnome.mkenums( +mkenums = gnome.mkenums( 'org.gnome.settings-daemon.enums.xml', sources: enums_header, comments: '', @@ -57,3 +58,12 @@ pkg.generate( filebase: meson.project_name(), subdirs: gsd_api_name ) + + +# for unit tests - gnome.compile_schemas() only looks in srcdir +custom_target('compile-schemas', + input: schemas_xml, + depends: mkenums, + output: 'gschemas.compiled', + command: [find_program('glib-compile-schemas'), meson.current_build_dir()], + build_by_default: true) diff --git a/tests/gsdtestcase.py b/tests/gsdtestcase.py index a3515c07..20bab9e0 100644 --- a/tests/gsdtestcase.py +++ b/tests/gsdtestcase.py @@ -69,6 +69,11 @@ class GSDTestCase(X11SessionTestCase): os.environ['XDG_DATA_HOME'] = os.path.join(klass.workdir, 'data') os.environ['XDG_RUNTIME_DIR'] = os.path.join(klass.workdir, 'runtime') + # Copy gschema file into XDG_DATA_HOME + gschema_dir = os.path.join(os.environ['XDG_DATA_HOME'], 'glib-2.0', 'schemas') + os.makedirs(gschema_dir) + shutil.copy(os.path.join(top_builddir, 'data', 'gschemas.compiled'), gschema_dir) + # work around https://bugzilla.gnome.org/show_bug.cgi?id=689136 os.makedirs(os.path.join(os.environ['XDG_CONFIG_HOME'], 'dconf')) os.makedirs(os.environ['XDG_RUNTIME_DIR'], mode=0o700) -- cgit v1.2.1