tests: Fix GCalManager test

The unit test that checks GCalManager test fails due to missing
schemas.

This patch allows schemas to be compiled in the build tree and also
sets the environment variables so tests can found them and run
properly.

Additional code and testing from Mohammed Sadiq <sadiq@sadiqpk.org>
This commit is contained in:
Iñigo Martínez
2018-02-11 23:17:12 +00:00
committed by Georges Basile Stavracas Neto
parent edbb4e5b86
commit 11fb4717a2
4 changed files with 56 additions and 37 deletions
+37 -11
View File
@@ -1,17 +1,32 @@
subdir('icons')
subdir('appdata')
enum_headers = files(join_paths(src_dir, 'gcal-enums.h'))
enums_xml = gnome.mkenums(
'org.gnome.calendar.enums.xml',
sources: enum_headers,
comments: '<!-- @comment@ -->',
fhead: '<schemalist>',
vhead: ' <@type@ id="org.gnome.calendar.@EnumName@">',
vprod: ' <value nick="@valuenick@" value="@valuenum@"/>',
vtail: ' </@type@>',
ftail: '</schemalist>',
install_header: true,
install_dir: calendar_schemadir
)
# Desktop files
# Note: This name is registered in gcal-weather-service.c.
desktop = 'org.gnome.Calendar.desktop'
i18n.merge_file(
desktop,
type: 'desktop',
input: desktop + '.in',
output: desktop,
po_dir: po_dir,
install: true,
desktop,
type: 'desktop',
input: desktop + '.in',
output: desktop,
po_dir: po_dir,
install: true,
install_dir: join_paths(calendar_datadir, 'applications')
)
@@ -27,7 +42,7 @@ schema_conf.set('GETTEXT_PACKAGE', meson.project_name())
schema = 'org.gnome.calendar.gschema.xml'
configure_file(
schema_xml = configure_file(
input: schema + '.in',
output: schema,
install: true,
@@ -35,6 +50,17 @@ configure_file(
configuration: schema_conf
)
output = 'gschemas.compiled'
# for unit tests - gnome.compile_schemas() only looks in srcdir
compiled_schemas = custom_target(
output,
input: schema_xml,
output: output,
command: [find_program('glib-compile-schemas'), meson.current_build_dir()],
depends: enums_xml
)
# DBus service files
service_conf = configuration_data()
service_conf.set('bindir', calendar_bindir)
@@ -42,10 +68,10 @@ service_conf.set('bindir', calendar_bindir)
service = 'org.gnome.Calendar.service'
configure_file(
input: service + '.in',
output: service,
install: true,
install_dir: join_paths(calendar_datadir, 'dbus-1', 'services'),
input: service + '.in',
output: service,
install: true,
install_dir: join_paths(calendar_datadir, 'dbus-1', 'services'),
configuration: service_conf
)
+1
View File
@@ -136,6 +136,7 @@ top_inc = include_directories('.')
data_dir = join_paths(meson.source_root(), 'data')
po_dir = join_paths(meson.source_root(), 'po')
src_dir = join_paths(meson.source_root(), 'src')
###########
-15
View File
@@ -1,7 +1,5 @@
src_inc = include_directories('.')
enum_headers = files('gcal-enums.h')
gcal_deps = [
gsettings_desktop_schemas_dep,
libedataserverui_dep,
@@ -56,19 +54,6 @@ sources = files(
'gcal-timer.c'
)
gnome.mkenums(
'org.gnome.calendar.enums.xml',
sources: enum_headers,
comments: '<!-- @comment@ -->',
fhead: '<schemalist>',
vhead: ' <@type@ id="org.gnome.calendar.@EnumName@">',
vprod: ' <value nick="@valuenick@" value="@valuenum@"/>',
vtail: ' </@type@>',
ftail: '</schemalist>',
install_header: true,
install_dir: calendar_schemadir
)
enum_types = 'gcal-enum-types'
sources += gnome.mkenums(
+18 -11
View File
@@ -1,19 +1,26 @@
test_incs = [
include_directories('.'),
src_inc
]
tests_deps = gcal_deps + [ libgcal_dep ]
test_deps = gcal_deps + [ libgcal_dep ]
###########
# Manager #
###########
test_env = [
'G_TEST_SRCDIR=' + meson.current_source_dir(),
'G_TEST_BUILDDIR=' + meson.current_build_dir(),
'GSETTINGS_SCHEMA_DIR=' + join_paths(meson.build_root(), 'data'),
'GSETTINGS_BACKEND=memory',
'MALLOC_CHECK_=2'
]
test_cflags = '-DTEST_DATA_DIR="@0@"'.format(join_paths(meson.source_root(), 'data'))
test_unit = 'test-manager'
test_manager = executable(
'test-manager',
'test-manager.c',
dependencies: tests_deps,
include_directories: test_incs
test_unit,
[test_unit + '.c', compiled_schemas],
c_args: test_cflags,
dependencies: test_deps
)
test('test-manager', test_manager)
test(test_unit, test_manager, env: test_env)