[libpeas: 7/18] Don't use g_atexit() in the tests



commit 5bb42425fbabc4514b8701e520f055fde766f700
Author: Garrett Regier <alias301 gmail com>
Date:   Thu Mar 3 04:13:11 2011 -0800

    Don't use g_atexit() in the tests
    
    It seems that gcov will not register statements that are called
    in an atexit() handler so add testing_run_tests() to run
    the tests and then call peas_engine_shutdown().

 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       |   15 +++++++++++++++
 tests/libpeas-gtk/testing/testing.h       |    2 ++
 tests/libpeas/engine.c                    |    2 +-
 tests/libpeas/extension-python.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.h |    2 +-
 tests/libpeas/testing/testing.c           |   17 +++++++++++++++--
 tests/libpeas/testing/testing.h           |    3 +++
 13 files changed, 44 insertions(+), 11 deletions(-)
---
diff --git a/tests/libpeas-gtk/plugin-manager-store.c b/tests/libpeas-gtk/plugin-manager-store.c
index 7c32164..df7e9de 100644
--- a/tests/libpeas-gtk/plugin-manager-store.c
+++ b/tests/libpeas-gtk/plugin-manager-store.c
@@ -362,5 +362,5 @@ main (int    argc,
 
 #undef TEST
 
-  return g_test_run ();
+  return testing_run_tests ();
 }
diff --git a/tests/libpeas-gtk/plugin-manager-view.c b/tests/libpeas-gtk/plugin-manager-view.c
index 0bbb93d..b0010d1 100644
--- a/tests/libpeas-gtk/plugin-manager-view.c
+++ b/tests/libpeas-gtk/plugin-manager-view.c
@@ -263,5 +263,5 @@ main (int    argc,
 
 #undef TEST
 
-  return g_test_run ();
+  return testing_run_tests ();
 }
diff --git a/tests/libpeas-gtk/plugin-manager.c b/tests/libpeas-gtk/plugin-manager.c
index fb380a6..60b0d5d 100644
--- a/tests/libpeas-gtk/plugin-manager.c
+++ b/tests/libpeas-gtk/plugin-manager.c
@@ -451,5 +451,5 @@ main (int    argc,
 
 #undef TEST
 
-  return g_test_run ();
+  return testing_run_tests ();
 }
diff --git a/tests/libpeas-gtk/testing/testing.c b/tests/libpeas-gtk/testing/testing.c
index 887d012..0ba277b 100644
--- a/tests/libpeas-gtk/testing/testing.c
+++ b/tests/libpeas-gtk/testing/testing.c
@@ -143,6 +143,21 @@ testing_engine_free (PeasEngine *engine_)
     }
 }
 
+int
+testing_run_tests (void)
+{
+  int retval;
+
+  retval = g_test_run ();
+
+  /* Cannot call this with atexit() because
+   * gcov does not register that it was called.
+   */
+  peas_engine_shutdown ();
+
+  return retval;
+}
+
 PeasPluginInfo *
 testing_get_plugin_info_for_iter (PeasGtkPluginManagerView *view,
                                   GtkTreeIter              *iter)
diff --git a/tests/libpeas-gtk/testing/testing.h b/tests/libpeas-gtk/testing/testing.h
index 58f96a4..1440acd 100644
--- a/tests/libpeas-gtk/testing/testing.h
+++ b/tests/libpeas-gtk/testing/testing.h
@@ -32,6 +32,8 @@ void            testing_init                     (void);
 PeasEngine     *testing_engine_new               (void);
 void            testing_engine_free              (PeasEngine *engine);
 
+int             testing_run_tests                (void);
+
 PeasPluginInfo *testing_get_plugin_info_for_iter (PeasGtkPluginManagerView *view,
                                                   GtkTreeIter              *iter);
 gboolean        testing_get_iter_for_plugin_info (PeasGtkPluginManagerView *view,
diff --git a/tests/libpeas/engine.c b/tests/libpeas/engine.c
index a8e549f..c084844 100644
--- a/tests/libpeas/engine.c
+++ b/tests/libpeas/engine.c
@@ -389,5 +389,5 @@ main (int    argc,
 
 #undef TEST
 
-  return g_test_run ();
+  return testing_run_tests ();
 }
diff --git a/tests/libpeas/extension-python.c b/tests/libpeas/extension-python.c
index 8de154f..2d7fa25 100644
--- a/tests/libpeas/extension-python.c
+++ b/tests/libpeas/extension-python.c
@@ -62,5 +62,5 @@ main (int   argc,
   _EXTENSION_TEST ("python", "properties-readwrite", properties_readwrite);
 #endif
 
-  return g_test_run ();
+  return testing_run_tests ();
 }
diff --git a/tests/libpeas/extension-seed.c b/tests/libpeas/extension-seed.c
index a96a71e..a5b0961 100644
--- a/tests/libpeas/extension-seed.c
+++ b/tests/libpeas/extension-seed.c
@@ -64,5 +64,5 @@ main (int   argc,
   _EXTENSION_TEST ("seed", "properties-readwrite", properties_readwrite);
 #endif
 
-  return g_test_run ();
+  return testing_run_tests ();
 }
diff --git a/tests/libpeas/extension-set.c b/tests/libpeas/extension-set.c
index 77b73c0..84000c5 100644
--- a/tests/libpeas/extension-set.c
+++ b/tests/libpeas/extension-set.c
@@ -214,5 +214,5 @@ main (int    argc,
 
 #undef TEST
 
-  return g_test_run ();
+  return testing_run_tests ();
 }
diff --git a/tests/libpeas/plugin-info.c b/tests/libpeas/plugin-info.c
index 6992386..58f0d66 100644
--- a/tests/libpeas/plugin-info.c
+++ b/tests/libpeas/plugin-info.c
@@ -212,5 +212,5 @@ main (int    argc,
 
 #undef TEST
 
-  return g_test_run ();
+  return testing_run_tests ();
 }
diff --git a/tests/libpeas/testing/testing-extension.h b/tests/libpeas/testing/testing-extension.h
index a57cc31..38e2808 100644
--- a/tests/libpeas/testing/testing-extension.h
+++ b/tests/libpeas/testing/testing-extension.h
@@ -96,7 +96,7 @@ main (int   argc, \
   _EXTENSION_TEST (loader, "properties-write-only", properties_write_only); \
   _EXTENSION_TEST (loader, "properties-readwrite", properties_readwrite); \
 \
-  return g_test_run (); \
+  return testing_run_tests (); \
 }
 
 G_END_DECLS
diff --git a/tests/libpeas/testing/testing.c b/tests/libpeas/testing/testing.c
index 9f58c09..66a8614 100644
--- a/tests/libpeas/testing/testing.c
+++ b/tests/libpeas/testing/testing.c
@@ -114,8 +114,6 @@ testing_init (void)
                                  "Introspection", "1.0", 0, &error);
   g_assert_no_error (error);
 
-  g_atexit (peas_engine_shutdown);
-
   initialized = TRUE;
 }
 
@@ -152,3 +150,18 @@ testing_engine_free (PeasEngine *engine_)
       g_assert (engine == NULL);
     }
 }
+
+int
+testing_run_tests (void)
+{
+  int retval;
+
+  retval = g_test_run ();
+
+  /* Cannot call this with atexit() because
+   * gcov does not register that it was called.
+   */
+  peas_engine_shutdown ();
+
+  return retval;
+}
diff --git a/tests/libpeas/testing/testing.h b/tests/libpeas/testing/testing.h
index 4c20595..208d7a9 100644
--- a/tests/libpeas/testing/testing.h
+++ b/tests/libpeas/testing/testing.h
@@ -31,6 +31,9 @@ void        testing_init        (void);
 PeasEngine *testing_engine_new  (void);
 void        testing_engine_free (PeasEngine *engine);
 
+int         testing_run_tests   (void);
+
+
 G_END_DECLS
 
 #endif /* __TESTING_H__ */



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