[libpeas] Make calling testing_init() required



commit ff48b37e609008d7cbefb1c913c89ceabd68276f
Author: Garrett Regier <garrettregier gmail com>
Date:   Thu Feb 14 00:38:04 2013 -0800

    Make calling testing_init() required
    
    Also encapsulate the order in which {g,gtk}_test_init()
    must be called.

 tests/libpeas-gtk/plugin-manager-store.c  |    2 +-
 tests/libpeas-gtk/plugin-manager-view.c   |    2 +-
 tests/libpeas-gtk/plugin-manager.c        |    2 +-
 tests/libpeas-gtk/testing/testing.c       |   10 +++++-----
 tests/libpeas-gtk/testing/testing.h       |   15 ++++++++-------
 tests/libpeas/engine.c                    |    2 +-
 tests/libpeas/extension-c.c               |    2 +-
 tests/libpeas/extension-gjs.c             |    2 +-
 tests/libpeas/extension-python.c          |    2 +-
 tests/libpeas/extension-python3.c         |    2 +-
 tests/libpeas/extension-seed.c            |    2 +-
 tests/libpeas/extension-set.c             |    2 +-
 tests/libpeas/plugin-info.c               |    2 +-
 tests/libpeas/testing/testing-extension.c |    2 --
 tests/libpeas/testing/testing.c           |   11 ++++++-----
 tests/libpeas/testing/testing.h           |    3 ++-
 tests/testing-util/testing-util.c         |    8 +++++---
 17 files changed, 37 insertions(+), 34 deletions(-)
---
diff --git a/tests/libpeas-gtk/plugin-manager-store.c b/tests/libpeas-gtk/plugin-manager-store.c
index 83aa47e..0b3d77d 100644
--- a/tests/libpeas-gtk/plugin-manager-store.c
+++ b/tests/libpeas-gtk/plugin-manager-store.c
@@ -297,7 +297,7 @@ int
 main (int    argc,
       char **argv)
 {
-  gtk_test_init (&argc, &argv, NULL);
+  testing_init (&argc, &argv);
 
 #define TEST(path, ftest) \
   g_test_add ("/gtk/plugin-manager-store/" path, TestFixture, \
diff --git a/tests/libpeas-gtk/plugin-manager-view.c b/tests/libpeas-gtk/plugin-manager-view.c
index 00dbacb..6f48520 100644
--- a/tests/libpeas-gtk/plugin-manager-view.c
+++ b/tests/libpeas-gtk/plugin-manager-view.c
@@ -242,7 +242,7 @@ int
 main (int    argc,
       char **argv)
 {
-  gtk_test_init (&argc, &argv, NULL);
+  testing_init (&argc, &argv);
 
 #define TEST(path, ftest) \
   g_test_add ("/gtk/plugin-manager-view/" path, TestFixture, \
diff --git a/tests/libpeas-gtk/plugin-manager.c b/tests/libpeas-gtk/plugin-manager.c
index bba1734..77c35e1 100644
--- a/tests/libpeas-gtk/plugin-manager.c
+++ b/tests/libpeas-gtk/plugin-manager.c
@@ -463,7 +463,7 @@ int
 main (int    argc,
       char **argv)
 {
-  gtk_test_init (&argc, &argv, NULL);
+  testing_init (&argc, &argv);
 
 #define TEST(path, ftest) \
   g_test_add ("/gtk/plugin-manager/" path, TestFixture, \
diff --git a/tests/libpeas-gtk/testing/testing.c b/tests/libpeas-gtk/testing/testing.c
index ba2575a..f95d4b9 100644
--- a/tests/libpeas-gtk/testing/testing.c
+++ b/tests/libpeas-gtk/testing/testing.c
@@ -32,7 +32,8 @@
 #include "testing.h"
 
 void
-testing_init (void)
+testing_init (gint    *argc,
+              gchar ***argv)
 {
   GError *error = NULL;
   static gboolean initialized = FALSE;
@@ -40,6 +41,9 @@ testing_init (void)
   if (initialized)
     return;
 
+  gtk_test_init (argc, argv, NULL);
+
+  /* Must be after gtk_test_init() changes the log settings*/
   testing_util_init ();
 
   g_irepository_prepend_search_path (BUILDDIR "/libpeas-gtk");
@@ -55,11 +59,7 @@ testing_engine_new (void)
 {
   PeasEngine *engine;
 
-  testing_init ();
-
-  /* Must be after requiring typelibs */
   engine = testing_util_engine_new ();
-
   peas_engine_add_search_path (engine, BUILDDIR "/tests/libpeas-gtk/plugins",
                                        SRCDIR   "/tests/libpeas-gtk/plugins");
 
diff --git a/tests/libpeas-gtk/testing/testing.h b/tests/libpeas-gtk/testing/testing.h
index c96fbe7..8ba595c 100644
--- a/tests/libpeas-gtk/testing/testing.h
+++ b/tests/libpeas-gtk/testing/testing.h
@@ -28,17 +28,18 @@
 
 G_BEGIN_DECLS
 
-void            testing_init                     (void);
+void            testing_init                     (gint                       *argc,
+                                                  gchar                    ***argv);
 
 PeasEngine     *testing_engine_new               (void);
 
-PeasPluginInfo *testing_get_plugin_info_for_iter (PeasGtkPluginManagerView *view,
-                                                  GtkTreeIter              *iter);
-gboolean        testing_get_iter_for_plugin_info (PeasGtkPluginManagerView *view,
-                                                  PeasPluginInfo           *info,
-                                                  GtkTreeIter              *iter);
+PeasPluginInfo *testing_get_plugin_info_for_iter (PeasGtkPluginManagerView   *view,
+                                                  GtkTreeIter                *iter);
+gboolean        testing_get_iter_for_plugin_info (PeasGtkPluginManagerView   *view,
+                                                  PeasPluginInfo             *info,
+                                                  GtkTreeIter                *iter);
 
-void            testing_show_widget              (gpointer                  widget);
+void            testing_show_widget              (gpointer                    widget);
 
 /* libtesting-util functions which do not need to be overridden */
 #define testing_engine_free testing_util_engine_free
diff --git a/tests/libpeas/engine.c b/tests/libpeas/engine.c
index 42f97ff..c8f4848 100644
--- a/tests/libpeas/engine.c
+++ b/tests/libpeas/engine.c
@@ -450,7 +450,7 @@ int
 main (int    argc,
       char **argv)
 {
-  g_test_init (&argc, &argv, NULL);
+  testing_init (&argc, &argv);
 
 #define TEST(path, ftest) \
   g_test_add ("/engine/" path, TestFixture, \
diff --git a/tests/libpeas/extension-c.c b/tests/libpeas/extension-c.c
index b55559f..950f7e5 100644
--- a/tests/libpeas/extension-c.c
+++ b/tests/libpeas/extension-c.c
@@ -65,7 +65,7 @@ int
 main (int   argc,
       char *argv[])
 {
-  g_test_init (&argc, &argv, NULL);
+  testing_init (&argc, &argv);
 
   /* Only test the basics */
   testing_extension_basic ("c");
diff --git a/tests/libpeas/extension-gjs.c b/tests/libpeas/extension-gjs.c
index 3db6776..38358de 100644
--- a/tests/libpeas/extension-gjs.c
+++ b/tests/libpeas/extension-gjs.c
@@ -47,7 +47,7 @@ int
 main (int   argc,
       char *argv[])
 {
-  g_test_init (&argc, &argv, NULL);
+  testing_init (&argc, &argv);
 
   testing_extension_all ("gjs");
 
diff --git a/tests/libpeas/extension-python.c b/tests/libpeas/extension-python.c
index f000371..30f2be0 100644
--- a/tests/libpeas/extension-python.c
+++ b/tests/libpeas/extension-python.c
@@ -111,7 +111,7 @@ int
 main (int   argc,
       char *argv[])
 {
-  g_test_init (&argc, &argv, NULL);
+  testing_init (&argc, &argv);
 
   testing_extension_all ("python");
 
diff --git a/tests/libpeas/extension-python3.c b/tests/libpeas/extension-python3.c
index dbd0d44..fc5e61b 100644
--- a/tests/libpeas/extension-python3.c
+++ b/tests/libpeas/extension-python3.c
@@ -111,7 +111,7 @@ int
 main (int   argc,
       char *argv[])
 {
-  g_test_init (&argc, &argv, NULL);
+  testing_init (&argc, &argv);
 
   testing_extension_all ("python3");
 
diff --git a/tests/libpeas/extension-seed.c b/tests/libpeas/extension-seed.c
index c5fe117..28ed12e 100644
--- a/tests/libpeas/extension-seed.c
+++ b/tests/libpeas/extension-seed.c
@@ -46,7 +46,7 @@ int
 main (int   argc,
       char *argv[])
 {
-  g_test_init (&argc, &argv, NULL);
+  testing_init (&argc, &argv);
 
   testing_extension_all ("seed");
 
diff --git a/tests/libpeas/extension-set.c b/tests/libpeas/extension-set.c
index 5d7d2ed..bbb9668 100644
--- a/tests/libpeas/extension-set.c
+++ b/tests/libpeas/extension-set.c
@@ -290,7 +290,7 @@ int
 main (int    argc,
       char **argv)
 {
-  g_test_init (&argc, &argv, NULL);
+  testing_init (&argc, &argv);
 
 #define TEST(path, ftest) \
   g_test_add ("/extension-set/" path, TestFixture, \
diff --git a/tests/libpeas/plugin-info.c b/tests/libpeas/plugin-info.c
index bf0e3df..256584f 100644
--- a/tests/libpeas/plugin-info.c
+++ b/tests/libpeas/plugin-info.c
@@ -180,7 +180,7 @@ int
 main (int    argc,
       char **argv)
 {
-  g_test_init (&argc, &argv, NULL);
+  testing_init (&argc, &argv);
 
 #define TEST(path, ftest) \
   g_test_add ("/plugin-info/" path, TestFixture, \
diff --git a/tests/libpeas/testing/testing-extension.c b/tests/libpeas/testing/testing-extension.c
index 7b2b394..c1efd53 100644
--- a/tests/libpeas/testing/testing-extension.c
+++ b/tests/libpeas/testing/testing-extension.c
@@ -485,8 +485,6 @@ testing_extension_basic (const gchar *loader)
 {
   PeasEngine *engine;
 
-  testing_init ();
-
   extension_plugin = g_strdup_printf ("extension-%s", loader);
 
   engine = testing_engine_new ();
diff --git a/tests/libpeas/testing/testing.c b/tests/libpeas/testing/testing.c
index 078542e..e0ab839 100644
--- a/tests/libpeas/testing/testing.c
+++ b/tests/libpeas/testing/testing.c
@@ -32,7 +32,8 @@
 #include "testing.h"
 
 void
-testing_init (void)
+testing_init (gint    *argc,
+              gchar ***argv)
 {
   GError *error = NULL;
   static gboolean initialized = FALSE;
@@ -40,6 +41,9 @@ testing_init (void)
   if (initialized)
     return;
 
+  g_test_init (argc, argv, NULL);
+
+  /* Must be after g_test_init() changes the log settings*/
   testing_util_init ();
 
   g_irepository_require_private (g_irepository_get_default (),
@@ -55,8 +59,6 @@ testing_engine_new (void)
 {
   PeasEngine *engine;
 
-  testing_init ();
-
   testing_util_push_log_hook ("*Bad plugin file: *invalid.plugin*");
   testing_util_push_log_hook ("*Error loading *invalid.plugin*");
 
@@ -65,9 +67,8 @@ testing_engine_new (void)
   testing_util_push_log_hook ("*Error loading *info-missing-module.plugin*");
   testing_util_push_log_hook ("*Error loading *info-missing-name.plugin*");
 
-  /* Must be after requiring typelibs */
+  /* Must be after pushing log hooks */
   engine = testing_util_engine_new ();
-
   peas_engine_add_search_path (engine, BUILDDIR "/tests/libpeas/plugins",
                                        SRCDIR   "/tests/libpeas/plugins");
 
diff --git a/tests/libpeas/testing/testing.h b/tests/libpeas/testing/testing.h
index 12c951d..f638268 100644
--- a/tests/libpeas/testing/testing.h
+++ b/tests/libpeas/testing/testing.h
@@ -27,7 +27,8 @@
 
 G_BEGIN_DECLS
 
-void        testing_init        (void);
+void        testing_init        (gint    *argc,
+                                 gchar ***argv);
 
 PeasEngine *testing_engine_new  (void);
 
diff --git a/tests/testing-util/testing-util.c b/tests/testing-util/testing-util.c
index a97bcbd..7c78384 100644
--- a/tests/testing-util/testing-util.c
+++ b/tests/testing-util/testing-util.c
@@ -39,6 +39,7 @@ typedef struct {
 
 static PeasEngine *engine = NULL;
 static GPtrArray *log_hooks = NULL;
+static gboolean initialized = FALSE;
 
 /* These are warnings and criticals that just have to happen
  * for testing purposes and as such we don't want to abort on them.
@@ -119,7 +120,6 @@ void
 testing_util_init (void)
 {
   GError *error = NULL;
-  static gboolean initialized = FALSE;
 
   if (initialized)
     return;
@@ -153,13 +153,13 @@ testing_util_init (void)
 PeasEngine *
 testing_util_engine_new (void)
 {
+  g_assert (initialized);
+
   /* testing_util_engine_free() checks that the
    * engine is freed so only one engine can be created
    */
   g_assert (engine == NULL);
 
-  testing_util_init ();
-
   /* Must be after requiring typelibs */
   engine = peas_engine_new ();
 
@@ -192,6 +192,8 @@ testing_util_run_tests (void)
 {
   int retval;
 
+  g_assert (initialized);
+
   retval = g_test_run ();
 
   if (log_hooks != NULL)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]