[gnome-builder] tests: fix make check breakage
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] tests: fix make check breakage
- Date: Mon, 7 Sep 2015 00:11:45 +0000 (UTC)
commit a05a068c4b6eb54602fdd4223ed5237faf66a9be
Author: Christian Hergert <christian hergert me>
Date: Sun Sep 6 17:11:30 2015 -0700
tests: fix make check breakage
These were broken due to Devhelp performing g_warning()
on invalid xml files.
tests/Makefile.am | 36 +++++++++++++++------------
tests/test-helper.c | 48 ++++++++++++++++++++++++++++++++++++
tests/test-helper.h | 27 ++++++++++++++++++++
tests/test-ide-back-forward-list.c | 7 +++--
tests/test-ide-buffer-manager.c | 7 +++--
tests/test-ide-buffer.c | 7 +++--
tests/test-ide-context.c | 7 +++--
tests/test-ide-indenter.c | 47 ++---------------------------------
tests/test-vim.c | 6 ++--
9 files changed, 117 insertions(+), 75 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1d0de47..27510ab 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -47,7 +47,6 @@ tests_cflags = \
-I$(top_srcdir)/src/documents \
-I$(top_srcdir)/src/editor \
-I$(top_srcdir)/src/greeter \
- -I$(top_srcdir)/src/html \
-I$(top_srcdir)/src/keybindings \
-I$(top_srcdir)/src/preferences \
-I$(top_srcdir)/src/project-tree \
@@ -70,64 +69,69 @@ tests_ldflags = \
-export-dynamic \
$(NULL)
+test_files = \
+ test-helper.c \
+ test-helper.h
+
misc_programs =
TESTS_ENVIRONMENT= \
- GI_TYPELIB_PATH="$(top_srcdir)/libide" \
- G_TEST_SRCDIR="$(abs_srcdir)" \
- G_TEST_BUILDDIR="$(abs_builddir)" \
- G_DEBUG=gc-friendly \
- GB_IN_TREE_PLUGINS=1 \
- MALLOC_CHECK_=2 \
+ GI_TYPELIB_PATH="$(top_builddir)/libide:$(top_builddir)/src:$(GI_TYPELIB_PATH)" \
+ GB_IN_TREE_PLUGINS=1 \
+ G_TEST_SRCDIR="$(abs_srcdir)" \
+ G_TEST_BUILDDIR="$(abs_builddir)" \
+ G_DEBUG=gc-friendly \
+ GB_IN_TREE_PLUGINS=1 \
+ MALLOC_CHECK_=2 \
MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256))
LOG_COMPILER = $(top_srcdir)/build/autotools/tap-test
TESTS = test-ide-context
-test_ide_context_SOURCES = test-ide-context.c
+test_ide_context_SOURCES = test-ide-context.c $(test_files)
test_ide_context_CFLAGS = $(tests_cflags)
test_ide_context_LDADD = $(tests_libs)
test_ide_context_LDFLAGS = $(tests_ldflags)
TESTS += test-ide-back-forward-list
-test_ide_back_forward_list_SOURCES = test-ide-back-forward-list.c
+test_ide_back_forward_list_SOURCES = test-ide-back-forward-list.c $(test_files)
test_ide_back_forward_list_CFLAGS = $(tests_cflags)
test_ide_back_forward_list_LDADD = $(tests_libs)
TESTS += test-ide-buffer-manager
-test_ide_buffer_manager_SOURCES = test-ide-buffer-manager.c
+test_ide_buffer_manager_SOURCES = test-ide-buffer-manager.c $(test_files)
test_ide_buffer_manager_CFLAGS = $(tests_cflags)
test_ide_buffer_manager_LDADD = $(tests_libs)
TESTS += test-ide-buffer
-test_ide_buffer_SOURCES = test-ide-buffer.c
+test_ide_buffer_SOURCES = test-ide-buffer.c $(test_files)
test_ide_buffer_CFLAGS = $(tests_cflags)
test_ide_buffer_LDADD = $(tests_libs)
TESTS += test-ide-doap
-test_ide_doap_SOURCES = test-ide-doap.c
+test_ide_doap_SOURCES = test-ide-doap.c $(test_files)
test_ide_doap_CFLAGS = $(tests_cflags)
test_ide_doap_LDADD = $(tests_libs)
TESTS += test-ide-file-settings
-test_ide_file_settings_SOURCES = test-ide-file-settings.c
+test_ide_file_settings_SOURCES = test-ide-file-settings.c $(test_files)
test_ide_file_settings_CFLAGS = $(tests_cflags)
test_ide_file_settings_LDADD = $(tests_libs)
TESTS += test-ide-indenter
-test_ide_indenter_SOURCES = test-ide-indenter.c
+test_ide_indenter_SOURCES = test-ide-indenter.c $(test_files)
test_ide_indenter_CFLAGS = $(tests_cflags)
test_ide_indenter_LDADD = $(tests_libs)
TESTS += test-ide-vcs-uri
-test_ide_vcs_uri_SOURCES = test-ide-vcs-uri.c
+test_ide_vcs_uri_SOURCES = test-ide-vcs-uri.c $(test_files)
test_ide_vcs_uri_CFLAGS = $(tests_cflags)
test_ide_vcs_uri_LDADD = $(tests_libs)
@@ -143,7 +147,7 @@ test_ide_vcs_uri_LDADD = $(tests_libs)
TESTS += test-vim
-test_vim_SOURCES = test-vim.c
+test_vim_SOURCES = test-vim.c $(test_files)
test_vim_CFLAGS = \
$(tests_cflags) \
-I$(top_srcdir)/src/resources \
diff --git a/tests/test-helper.c b/tests/test-helper.c
new file mode 100644
index 0000000..69c5e0e
--- /dev/null
+++ b/tests/test-helper.c
@@ -0,0 +1,48 @@
+/* test-helper.c
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#include "gb-plugins.h"
+
+gboolean
+fatal_log_handler (const gchar *log_domain,
+ GLogLevelFlags log_level,
+ const gchar *message,
+ gpointer user_data)
+{
+ if (g_strcmp0 (log_domain, "Devhelp") == 0)
+ return FALSE;
+ return TRUE;
+}
+
+void
+test_helper_init (gint *argc,
+ gchar ***argv)
+{
+ gtk_init (argc, argv);
+ g_test_init (argc, argv, NULL);
+ gb_plugins_init ();
+}
+
+void
+test_helper_begin_test (void)
+{
+ g_test_log_set_fatal_handler (fatal_log_handler, NULL);
+}
diff --git a/tests/test-helper.h b/tests/test-helper.h
new file mode 100644
index 0000000..f78eab8
--- /dev/null
+++ b/tests/test-helper.h
@@ -0,0 +1,27 @@
+/* test-helper.h
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TEST_HELPER_H
+#define TEST_HELPER_H
+
+#include <glib.h>
+
+void test_helper_init (gint *argc, gchar ***argv);
+void test_helper_begin_test (void);
+
+#endif /* TEST_HELPER_H */
diff --git a/tests/test-ide-back-forward-list.c b/tests/test-ide-back-forward-list.c
index 5100b67..685ad80 100644
--- a/tests/test-ide-back-forward-list.c
+++ b/tests/test-ide-back-forward-list.c
@@ -20,6 +20,7 @@
#include <ide.h>
#include "gb-plugins.h"
+#include "test-helper.h"
typedef struct
{
@@ -147,6 +148,8 @@ test_basic (void)
GFile *project_file;
g_autofree gchar *path = NULL;
+ test_helper_begin_test ();
+
path = g_build_filename (g_get_current_dir (), TEST_DATA_DIR, "project1", "configure.ac", NULL);
project_file = g_file_new_for_path (path);
@@ -172,9 +175,7 @@ gint
main (gint argc,
gchar *argv[])
{
- gtk_init (&argc, &argv);
- g_test_init (&argc, &argv, NULL);
+ test_helper_init (&argc, &argv);
g_test_add_func ("/Ide/BackForwardList/basic", test_basic);
- gb_plugins_init ();
return g_test_run ();
}
diff --git a/tests/test-ide-buffer-manager.c b/tests/test-ide-buffer-manager.c
index 535668a..2df78e2 100644
--- a/tests/test-ide-buffer-manager.c
+++ b/tests/test-ide-buffer-manager.c
@@ -21,6 +21,7 @@
#include <ide.h>
#include "gb-plugins.h"
+#include "test-helper.h"
typedef struct
{
@@ -160,6 +161,8 @@ test_buffer_manager_basic (void)
g_autofree gchar *path = NULL;
const gchar *builddir = g_getenv ("G_TEST_BUILDDIR");
+ test_helper_begin_test ();
+
path = g_build_filename (builddir, "data", "project1", "configure.ac", NULL);
project_file = g_file_new_for_path (path);
@@ -194,9 +197,7 @@ gint
main (gint argc,
gchar *argv[])
{
- gtk_init (&argc, &argv);
- g_test_init (&argc, &argv, NULL);
+ test_helper_init (&argc, &argv);
g_test_add_func ("/Ide/BufferManager/basic", test_buffer_manager_basic);
- gb_plugins_init ();
return g_test_run ();
}
diff --git a/tests/test-ide-buffer.c b/tests/test-ide-buffer.c
index cacd8e6..ce4e263 100644
--- a/tests/test-ide-buffer.c
+++ b/tests/test-ide-buffer.c
@@ -21,6 +21,7 @@
#include <ide.h>
#include "gb-plugins.h"
+#include "test-helper.h"
typedef struct
{
@@ -113,6 +114,8 @@ test_buffer_basic (void)
GFile *project_file;
g_autofree gchar *path = NULL;
+ test_helper_begin_test ();
+
path = g_build_filename (g_get_current_dir (), TEST_DATA_DIR, "project1", "configure.ac", NULL);
project_file = g_file_new_for_path (path);
@@ -141,9 +144,7 @@ gint
main (gint argc,
gchar *argv[])
{
- gtk_init (&argc, &argv);
- g_test_init (&argc, &argv, NULL);
+ test_helper_init (&argc, &argv);
g_test_add_func ("/Ide/Buffer/basic", test_buffer_basic);
- gb_plugins_init ();
return g_test_run ();
}
diff --git a/tests/test-ide-context.c b/tests/test-ide-context.c
index 98f38c5..26acaba 100644
--- a/tests/test-ide-context.c
+++ b/tests/test-ide-context.c
@@ -19,6 +19,7 @@
#include <ide.h>
#include "gb-plugins.h"
+#include "test-helper.h"
typedef struct
{
@@ -49,6 +50,8 @@ test_new_async (void)
const gchar *builddir;
g_autofree gchar *path = NULL;
+ test_helper_begin_test ();
+
builddir = g_getenv ("G_TEST_BUILDDIR");
path = g_build_filename (builddir, "data", "project1", "configure.ac", NULL);
@@ -85,9 +88,7 @@ gint
main (gint argc,
gchar *argv[])
{
- gtk_init (&argc, &argv);
- g_test_init (&argc, &argv, NULL);
+ test_helper_init (&argc, &argv);
g_test_add_func ("/Ide/Context/new_async", test_new_async);
- gb_plugins_init ();
return g_test_run ();
}
diff --git a/tests/test-ide-indenter.c b/tests/test-ide-indenter.c
index 8bc169e..230f672 100644
--- a/tests/test-ide-indenter.c
+++ b/tests/test-ide-indenter.c
@@ -21,6 +21,7 @@
#include <string.h>
#include "gb-plugins.h"
+#include "test-helper.h"
typedef void (*IndentTestFunc) (IdeContext *context,
GtkWidget *widget);
@@ -32,46 +33,6 @@ typedef struct
} IndentTest;
static void
-load_plugins (void)
-{
- PeasEngine *engine;
- const GList *list;
- GDir *dir;
-
- engine = peas_engine_get_default ();
-
- if ((dir = g_dir_open ("../plugins", 0, NULL)))
- {
- const gchar *name;
-
- while ((name = g_dir_read_name (dir)))
- {
- gchar *path;
-
- path = g_build_filename ("..", "plugins", name, NULL);
- peas_engine_prepend_search_path (engine, path, path);
- g_free (path);
- }
-
- g_dir_close (dir);
- }
-
- peas_engine_rescan_plugins (engine);
- list = peas_engine_get_plugin_list (engine);
-
- for (; list; list = list->next)
- {
- PeasPluginInfo *info = list->data;
-
- if (g_strcmp0 (peas_plugin_info_get_module_name (info), "c-pack-plugin") == 0)
- {
- if (!peas_plugin_info_is_loaded (info))
- peas_engine_load_plugin (engine, info);
- }
- }
-}
-
-static void
new_context_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
@@ -288,7 +249,7 @@ test_cindenter_basic_cb (IdeContext *context,
static void
test_cindenter_basic (void)
{
- load_plugins ();
+ test_helper_begin_test ();
run_test ("test.c", test_cindenter_basic_cb);
}
@@ -297,9 +258,7 @@ gint
main (gint argc,
gchar *argv[])
{
- gtk_init (&argc, &argv);
- g_test_init (&argc, &argv, NULL);
+ test_helper_init (&argc, &argv);
g_test_add_func ("/Ide/CIndenter/basic", test_cindenter_basic);
- gb_plugins_init ();
return g_test_run ();
}
diff --git a/tests/test-vim.c b/tests/test-vim.c
index 9704d2a..cf1d3bb 100644
--- a/tests/test-vim.c
+++ b/tests/test-vim.c
@@ -21,6 +21,7 @@
#include "gb-plugins.h"
#include "gb-resources.h"
+#include "test-helper.h"
typedef void (*VimTestFunc) (IdeContext *context,
GtkWidget *widget);
@@ -255,6 +256,7 @@ test_vim_basic_cb (IdeContext *context,
static void
test_vim_basic (void)
{
+ test_helper_begin_test ();
run_test ("test.c", test_vim_basic_cb);
}
@@ -277,10 +279,8 @@ gint
main (gint argc,
gchar *argv[])
{
- gtk_init (&argc, &argv);
+ test_helper_init (&argc, &argv);
load_vim_css ();
- g_test_init (&argc, &argv, NULL);
g_test_add_func ("/Ide/Vim/basic", test_vim_basic);
- gb_plugins_init ();
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]