mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-11 15:06:14 +01:00
meson: gio/tests: add more gio tests
Need to fix up some of the tests a little, because the test binary will not necessarily be run from the current build sub-directory, and the build directory structure might not always be a mirror of the source directory structure, so pass location of glib-mkenums and glib-compile-scheme and such directly.
This commit is contained in:
parent
1acd6de763
commit
613e00826e
@ -773,7 +773,7 @@ executable('gio-querymodules', 'gio-querymodules.c',
|
|||||||
link_args : noseh_link_args,
|
link_args : noseh_link_args,
|
||||||
dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
|
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'],
|
[gconstructor_as_data_h, 'gvdb/gvdb-builder.c', 'glib-compile-schemas.c'],
|
||||||
install : true,
|
install : true,
|
||||||
c_args : ['-DHAVE_CONFIG_H=1'],
|
c_args : ['-DHAVE_CONFIG_H=1'],
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <glib/gstdio.h>
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include <gio/gdesktopappinfo.h>
|
#include <gio/gdesktopappinfo.h>
|
||||||
|
|
||||||
@ -474,10 +475,18 @@ test_from_keyfile (void)
|
|||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
const gchar *build_dir;
|
||||||
|
|
||||||
g_setenv ("XDG_CURRENT_DESKTOP", "GNOME", TRUE);
|
g_setenv ("XDG_CURRENT_DESKTOP", "GNOME", TRUE);
|
||||||
|
|
||||||
g_test_init (&argc, &argv, NULL);
|
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/basic", test_basic);
|
||||||
g_test_add_func ("/appinfo/text", test_text);
|
g_test_add_func ("/appinfo/text", test_text);
|
||||||
g_test_add_func ("/appinfo/launch", test_launch);
|
g_test_add_func ("/appinfo/launch", test_launch);
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <glib/glib.h>
|
#include <glib/glib.h>
|
||||||
|
#include <glib/gstdio.h>
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include <gio/gdesktopappinfo.h>
|
#include <gio/gdesktopappinfo.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -759,8 +760,15 @@ int
|
|||||||
main (int argc,
|
main (int argc,
|
||||||
char *argv[])
|
char *argv[])
|
||||||
{
|
{
|
||||||
|
const gchar *build_dir;
|
||||||
gint result;
|
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);
|
g_test_init (&argc, &argv, NULL);
|
||||||
|
|
||||||
basedir = g_get_current_dir ();
|
basedir = g_get_current_dir ();
|
||||||
|
@ -11,6 +11,11 @@ typedef struct {
|
|||||||
const gchar *err;
|
const gchar *err;
|
||||||
} SchemaTest;
|
} SchemaTest;
|
||||||
|
|
||||||
|
/* Meson build defines this, autotools build does not */
|
||||||
|
#ifndef GLIB_COMPILE_SCHEMAS
|
||||||
|
#define GLIB_COMPILE_SCHEMAS "../glib-compile-schemas"
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_schema_do_compile (gpointer data)
|
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 *filename = g_strconcat (test->name, ".gschema.xml", NULL);
|
||||||
gchar *path = g_test_build_filename (G_TEST_DIST, "schema-tests", filename, NULL);
|
gchar *path = g_test_build_filename (G_TEST_DIST, "schema-tests", filename, NULL);
|
||||||
gchar *argv[] = {
|
gchar *argv[] = {
|
||||||
"../glib-compile-schemas",
|
GLIB_COMPILE_SCHEMAS,
|
||||||
"--strict",
|
"--strict",
|
||||||
"--dry-run",
|
"--dry-run",
|
||||||
"--schema-file", path,
|
"--schema-file", path,
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
#include "testenum.h"
|
#include "testenum.h"
|
||||||
|
|
||||||
|
static const gchar *locale_dir = ".";
|
||||||
|
|
||||||
static gboolean backend_set;
|
static gboolean backend_set;
|
||||||
|
|
||||||
/* These tests rely on the schemas in org.gtk.test.gschema.xml
|
/* These tests rely on the schemas in org.gtk.test.gschema.xml
|
||||||
@ -732,7 +734,7 @@ test_l10n (void)
|
|||||||
gchar *str;
|
gchar *str;
|
||||||
gchar *locale;
|
gchar *locale;
|
||||||
|
|
||||||
bindtextdomain ("test", ".");
|
bindtextdomain ("test", locale_dir);
|
||||||
bind_textdomain_codeset ("test", "UTF-8");
|
bind_textdomain_codeset ("test", "UTF-8");
|
||||||
|
|
||||||
locale = g_strdup (setlocale (LC_MESSAGES, NULL));
|
locale = g_strdup (setlocale (LC_MESSAGES, NULL));
|
||||||
@ -779,7 +781,7 @@ test_l10n_context (void)
|
|||||||
gchar *str;
|
gchar *str;
|
||||||
gchar *locale;
|
gchar *locale;
|
||||||
|
|
||||||
bindtextdomain ("test", ".");
|
bindtextdomain ("test", locale_dir);
|
||||||
bind_textdomain_codeset ("test", "UTF-8");
|
bind_textdomain_codeset ("test", "UTF-8");
|
||||||
|
|
||||||
locale = g_strdup (setlocale (LC_MESSAGES, NULL));
|
locale = g_strdup (setlocale (LC_MESSAGES, NULL));
|
||||||
@ -2604,6 +2606,14 @@ main (int argc, char *argv[])
|
|||||||
gchar *enums;
|
gchar *enums;
|
||||||
gint result;
|
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, "");
|
setlocale (LC_ALL, "");
|
||||||
|
|
||||||
g_test_init (&argc, &argv, NULL);
|
g_test_init (&argc, &argv, NULL);
|
||||||
@ -2619,8 +2629,13 @@ main (int argc, char *argv[])
|
|||||||
if (!backend_set)
|
if (!backend_set)
|
||||||
g_setenv ("GSETTINGS_BACKEND", "memory", TRUE);
|
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_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 "
|
"--template " SRCDIR "/enums.xml.template "
|
||||||
SRCDIR "/testenum.h",
|
SRCDIR "/testenum.h",
|
||||||
&enums, NULL, &result, NULL));
|
&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_assert (g_file_set_contents ("org.gtk.test.gschema.xml", schema_text, -1, NULL));
|
||||||
g_free (schema_text);
|
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_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.enums.xml "
|
||||||
"--schema-file=org.gtk.test.gschema.xml",
|
"--schema-file=org.gtk.test.gschema.xml",
|
||||||
NULL, NULL, &result, NULL));
|
NULL, NULL, &result, NULL));
|
||||||
@ -2641,7 +2661,7 @@ main (int argc, char *argv[])
|
|||||||
|
|
||||||
g_remove ("schema-source/gschemas.compiled");
|
g_remove ("schema-source/gschemas.compiled");
|
||||||
g_mkdir ("schema-source", 0777);
|
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",
|
"--schema-file=" SRCDIR "/org.gtk.schemasourcecheck.gschema.xml",
|
||||||
NULL, NULL, &result, NULL));
|
NULL, NULL, &result, NULL));
|
||||||
g_assert (result == 0);
|
g_assert (result == 0);
|
||||||
|
@ -71,6 +71,8 @@ test_c_args = [
|
|||||||
'-DHAVE_CONFIG_H=1',
|
'-DHAVE_CONFIG_H=1',
|
||||||
'-DG_LOG_DOMAIN="GLib-GIO"',
|
'-DG_LOG_DOMAIN="GLib-GIO"',
|
||||||
'-DTEST_SERVICES="@0@/gio/tests/services"'.format(meson.build_root()),
|
'-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
|
# Check for libdbus1 - Optional - is only used in the GDBus test cases
|
||||||
@ -99,6 +101,14 @@ if host_machine.system() != 'windows'
|
|||||||
'unix-fd',
|
'unix-fd',
|
||||||
'unix-streams',
|
'unix-streams',
|
||||||
'mimeapps',
|
'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 += [
|
test_extra_programs += [
|
||||||
@ -186,11 +196,44 @@ if host_machine.system() != 'windows'
|
|||||||
dependencies : [libglib_dep, libgmodule_dep, libgio_dep])
|
dependencies : [libglib_dep, libgmodule_dep, libgio_dep])
|
||||||
test('gapplication', exe, env : test_env)
|
test('gapplication', exe, env : test_env)
|
||||||
|
|
||||||
if host_machine.system() != 'windows'
|
|
||||||
gio_tests += ['gdbus-unix-addresses']
|
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
|
endif # unix
|
||||||
endif
|
|
||||||
|
|
||||||
# Test programs buildable on Windows only
|
# Test programs buildable on Windows only
|
||||||
if host_machine.system() == 'windows'
|
if host_machine.system() == 'windows'
|
||||||
|
Loading…
Reference in New Issue
Block a user