diff --git a/gio/meson.build b/gio/meson.build index 80284e6f4..b04e5112e 100644 --- a/gio/meson.build +++ b/gio/meson.build @@ -773,7 +773,7 @@ executable('gio-querymodules', 'gio-querymodules.c', link_args : noseh_link_args, dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep]) -executable('glib-compile-schemas', +glib_compile_schemas = executable('glib-compile-schemas', [gconstructor_as_data_h, 'gvdb/gvdb-builder.c', 'glib-compile-schemas.c'], install : true, c_args : ['-DHAVE_CONFIG_H=1'], diff --git a/gio/tests/appinfo.c b/gio/tests/appinfo.c index b1a60f0b8..190205398 100644 --- a/gio/tests/appinfo.c +++ b/gio/tests/appinfo.c @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -474,10 +475,18 @@ test_from_keyfile (void) int main (int argc, char *argv[]) { + const gchar *build_dir; + g_setenv ("XDG_CURRENT_DESKTOP", "GNOME", TRUE); g_test_init (&argc, &argv, NULL); + /* With Meson build we need to change into right directory, so that the + * appinfo-test binary can be found. */ + build_dir = g_getenv ("G_TEST_BUILDDIR"); + if (build_dir) + g_chdir (build_dir); + g_test_add_func ("/appinfo/basic", test_basic); g_test_add_func ("/appinfo/text", test_text); g_test_add_func ("/appinfo/launch", test_launch); diff --git a/gio/tests/desktop-app-info.c b/gio/tests/desktop-app-info.c index 5fcb5c2e6..3086da428 100644 --- a/gio/tests/desktop-app-info.c +++ b/gio/tests/desktop-app-info.c @@ -18,6 +18,7 @@ */ #include +#include #include #include #include @@ -759,8 +760,15 @@ int main (int argc, char *argv[]) { + const gchar *build_dir; gint result; + /* With Meson build we need to change into right directory, so that the + * appinfo-test binary can be found. */ + build_dir = g_getenv ("G_TEST_BUILDDIR"); + if (build_dir) + g_chdir (build_dir); + g_test_init (&argc, &argv, NULL); basedir = g_get_current_dir (); diff --git a/gio/tests/gschema-compile.c b/gio/tests/gschema-compile.c index a215a846a..79eab97a7 100644 --- a/gio/tests/gschema-compile.c +++ b/gio/tests/gschema-compile.c @@ -11,6 +11,11 @@ typedef struct { const gchar *err; } SchemaTest; +/* Meson build defines this, autotools build does not */ +#ifndef GLIB_COMPILE_SCHEMAS +#define GLIB_COMPILE_SCHEMAS "../glib-compile-schemas" +#endif + static void test_schema_do_compile (gpointer data) { @@ -18,7 +23,7 @@ test_schema_do_compile (gpointer data) gchar *filename = g_strconcat (test->name, ".gschema.xml", NULL); gchar *path = g_test_build_filename (G_TEST_DIST, "schema-tests", filename, NULL); gchar *argv[] = { - "../glib-compile-schemas", + GLIB_COMPILE_SCHEMAS, "--strict", "--dry-run", "--schema-file", path, diff --git a/gio/tests/gsettings.c b/gio/tests/gsettings.c index 18db38805..2be4122fe 100644 --- a/gio/tests/gsettings.c +++ b/gio/tests/gsettings.c @@ -8,6 +8,8 @@ #include "testenum.h" +static const gchar *locale_dir = "."; + static gboolean backend_set; /* These tests rely on the schemas in org.gtk.test.gschema.xml @@ -732,7 +734,7 @@ test_l10n (void) gchar *str; gchar *locale; - bindtextdomain ("test", "."); + bindtextdomain ("test", locale_dir); bind_textdomain_codeset ("test", "UTF-8"); locale = g_strdup (setlocale (LC_MESSAGES, NULL)); @@ -779,7 +781,7 @@ test_l10n_context (void) gchar *str; gchar *locale; - bindtextdomain ("test", "."); + bindtextdomain ("test", locale_dir); bind_textdomain_codeset ("test", "UTF-8"); locale = g_strdup (setlocale (LC_MESSAGES, NULL)); @@ -2604,6 +2606,14 @@ main (int argc, char *argv[]) gchar *enums; gint result; +/* Meson build sets this */ +#ifdef TEST_LOCALE_PATH + if (g_str_has_suffix (TEST_LOCALE_PATH, "LC_MESSAGES")) + { + locale_dir = TEST_LOCALE_PATH G_DIR_SEPARATOR_S ".." G_DIR_SEPARATOR_S ".."; + } +#endif + setlocale (LC_ALL, ""); g_test_init (&argc, &argv, NULL); @@ -2619,8 +2629,13 @@ main (int argc, char *argv[]) if (!backend_set) g_setenv ("GSETTINGS_BACKEND", "memory", TRUE); +/* Meson build defines this, autotools build does not */ +#ifndef GLIB_MKENUMS +#define GLIB_MKENUMS "../../gobject/glib-mkenums" +#endif + g_remove ("org.gtk.test.enums.xml"); - g_assert (g_spawn_command_line_sync ("../../gobject/glib-mkenums " + g_assert (g_spawn_command_line_sync (GLIB_MKENUMS " " "--template " SRCDIR "/enums.xml.template " SRCDIR "/testenum.h", &enums, NULL, &result, NULL)); @@ -2632,8 +2647,13 @@ main (int argc, char *argv[]) g_assert (g_file_set_contents ("org.gtk.test.gschema.xml", schema_text, -1, NULL)); g_free (schema_text); +/* Meson build defines this, autotools build does not */ +#ifndef GLIB_COMPILE_SCHEMAS +#define GLIB_COMPILE_SCHEMAS "../glib-compile-schemas" +#endif + g_remove ("gschemas.compiled"); - g_assert (g_spawn_command_line_sync ("../glib-compile-schemas --targetdir=. " + g_assert (g_spawn_command_line_sync (GLIB_COMPILE_SCHEMAS " --targetdir=. " "--schema-file=org.gtk.test.enums.xml " "--schema-file=org.gtk.test.gschema.xml", NULL, NULL, &result, NULL)); @@ -2641,7 +2661,7 @@ main (int argc, char *argv[]) g_remove ("schema-source/gschemas.compiled"); g_mkdir ("schema-source", 0777); - g_assert (g_spawn_command_line_sync ("../glib-compile-schemas --targetdir=schema-source " + g_assert (g_spawn_command_line_sync (GLIB_COMPILE_SCHEMAS " --targetdir=schema-source " "--schema-file=" SRCDIR "/org.gtk.schemasourcecheck.gschema.xml", NULL, NULL, &result, NULL)); g_assert (result == 0); diff --git a/gio/tests/meson.build b/gio/tests/meson.build index 7e6eede24..d70b5b3cd 100644 --- a/gio/tests/meson.build +++ b/gio/tests/meson.build @@ -71,6 +71,8 @@ test_c_args = [ '-DHAVE_CONFIG_H=1', '-DG_LOG_DOMAIN="GLib-GIO"', '-DTEST_SERVICES="@0@/gio/tests/services"'.format(meson.build_root()), + '-DGLIB_MKENUMS="@0@"'.format(glib_mkenums), + '-DGLIB_COMPILE_SCHEMAS="@0@"'.format(glib_compile_schemas.full_path()), ] # Check for libdbus1 - Optional - is only used in the GDBus test cases @@ -99,6 +101,14 @@ if host_machine.system() != 'windows' 'unix-fd', 'unix-streams', 'mimeapps', + 'gschema-compile', + ] + + # Uninstalled because of the check-for-executable logic in DesktopAppInfo + # unable to find the installed executable + gio_tests += [ + 'appinfo', + 'desktop-app-info', ] test_extra_programs += [ @@ -186,11 +196,44 @@ if host_machine.system() != 'windows' dependencies : [libglib_dep, libgmodule_dep, libgio_dep]) test('gapplication', exe, env : test_env) - if host_machine.system() != 'windows' - gio_tests += ['gdbus-unix-addresses'] - endif + gio_tests += ['gdbus-unix-addresses'] + endif # have_dbus_daemon + + # This test is currently unreliable + executable('gdbus-overflow', 'gdbus-overflow.c', + install : false, + c_args : test_c_args, + dependencies : [libglib_dep, libgmodule_dep, libgio_dep]) + + exe = executable('gdbus-connection-flush', 'gdbus-connection-flush.c', + 'test-io-stream.c', 'test-pipe-unix.c', + install : false, + c_args : test_c_args, + dependencies : [libglib_dep, libgmodule_dep, libgio_dep]) + test('gdbus-connection-flush', exe, env : test_env) + + exe = executable('gdbus-non-socket', 'gdbus-non-socket.c', + 'gdbus-tests.c', 'test-io-stream.c', 'test-pipe-unix.c', + install : false, + c_args : test_c_args, + dependencies : [libglib_dep, libgmodule_dep, libgio_dep]) + test('gdbus-non-socket', exe, env : test_env) + + # Generate test.mo from de.po using msgfmt + msgfmt = find_program('msgfmt', required : false) + if msgfmt.found() + subdir('de/LC_MESSAGES') + # gsettings target exe already exists in gio directory + exe = executable('gsettings-test', 'gsettings.c', test_mo, + install : false, + c_args : test_c_args + [ + '-DSRCDIR="@0@"'.format(meson.current_source_dir()), + '-DTEST_LOCALE_PATH="@0@"'.format(test_mo_dir), + ], + dependencies : [libglib_dep, libgmodule_dep, libgio_dep]) + test('gsettings', exe, env : test_env) endif -endif +endif # unix # Test programs buildable on Windows only if host_machine.system() == 'windows'