meson: tests: make tests find resources from the source dir

Should probably also do this in the autotools build, since
the same problem exists there as well if we use srcdir != builddir.
This commit is contained in:
Tim-Philipp Müller 2017-03-12 18:36:21 +00:00 committed by Emmanuele Bassi
parent 08153c3854
commit d276cd47a5
9 changed files with 48 additions and 3 deletions

View File

@ -137,12 +137,16 @@ if x11_enabled
gtk_tests += [['testerrors']]
endif
# TODO: need to pass source dir so progs can find .ui files and such
# (with autotools this only works in the builddir == srcdir case)
# Pass the source dir here so programs can change into the source directory
# and find .ui files and .png files and such that they load at runtime
test_args = ['-DGTK_SRCDIR="@0@"'.format(meson.current_source_dir())]
foreach t : gtk_tests
test_name = t.get(0)
test_srcs = ['@0@.c'.format(test_name), t.get(1, [])]
executable(test_name, test_srcs, dependencies: [libgtk_dep, libm])
executable(test_name, test_srcs,
c_args : test_args,
dependencies : [libgtk_dep, libm])
endforeach
subdir('visuals')

View File

@ -1,4 +1,5 @@
#include <gtk/gtk.h>
#include <glib/gstdio.h>
static void
show_message_dialog1 (GtkWindow *parent)
@ -316,6 +317,10 @@ main (int argc, char *argv[])
GtkWidget *box;
GtkWidget *button;
#ifdef GTK_SRCDIR
g_chdir (GTK_SRCDIR);
#endif
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

View File

@ -17,6 +17,7 @@
*/
#include <gtk/gtk.h>
#include <glib/gstdio.h>
int
main (int argc,
@ -28,6 +29,10 @@ main (int argc,
GEmblem *emblem;
gchar *str;
#ifdef GTK_SRCDIR
g_chdir (GTK_SRCDIR);
#endif
gtk_init ();
pixbuf = gdk_pixbuf_new_from_file ("apple-red.png", NULL);

View File

@ -37,6 +37,8 @@
#include <unistd.h>
#endif
#include <glib/gstdio.h>
#include "gtk/gtk.h"
#include "gdk/gdk.h"
#include "gdk/gdkkeysyms.h"
@ -8805,6 +8807,10 @@ main (int argc, char *argv[])
g_set_application_name ("GTK+ Test Program");
#ifdef GTK_SRCDIR
g_chdir (GTK_SRCDIR);
#endif
gtk_init ();
provider = gtk_css_provider_new ();

View File

@ -16,6 +16,7 @@
*/
#include <gtk/gtk.h>
#include <glib/gstdio.h>
#include <sys/types.h>
#include <string.h>
@ -420,6 +421,10 @@ main (gint argc, gchar **argv)
GtkCellRenderer *cell;
GtkTreeViewColumn *tvc;
#ifdef GTK_SRCDIR
g_chdir (GTK_SRCDIR);
#endif
gtk_init ();
/* to test rtl layout, set RTL=1 in the environment */

View File

@ -1,4 +1,5 @@
#include <gtk/gtk.h>
#include <glib/gstdio.h>
static void
activate (GSimpleAction *action,
@ -48,6 +49,10 @@ main (int argc, char *argv[])
GtkWidget *check;
GtkWidget *combo;
#ifdef GTK_SRCDIR
g_chdir (GTK_SRCDIR);
#endif
gtk_init ();
win = gtk_window_new (GTK_WINDOW_TOPLEVEL);

View File

@ -1,4 +1,5 @@
#include <gtk/gtk.h>
#include <glib/gstdio.h>
typedef struct {
GtkListBoxRow parent;
@ -179,6 +180,10 @@ main (int argc, char *argv[])
GSimpleActionGroup *group;
GSimpleAction *action;
#ifdef GTK_SRCDIR
g_chdir (GTK_SRCDIR);
#endif
gtk_init ();
builder = gtk_builder_new_from_file ("selectionmode.ui");

View File

@ -1,4 +1,5 @@
#include <gtk/gtk.h>
#include <glib/gstdio.h>
static void
split_decorations (GtkSettings *settings,
@ -42,6 +43,10 @@ main (int argc, char *argv[])
GtkWidget *check;
GtkWidget *header;
#ifdef GTK_SRCDIR
g_chdir (GTK_SRCDIR);
#endif
gtk_init ();
builder = gtk_builder_new_from_file ("testsplitheaders.ui");

View File

@ -1,4 +1,5 @@
#include <gtk/gtk.h>
#include <glib/gstdio.h>
static GtkWidget *header_stack;
static GtkWidget *page_stack;
@ -23,6 +24,10 @@ main (int argc, char *argv[])
GtkBuilder *builder;
GtkWidget *win;
#ifdef GTK_SRCDIR
g_chdir (GTK_SRCDIR);
#endif
gtk_init ();
builder = gtk_builder_new ();