[libpeas] Use g_test_trap_subprocess() instead of g_test_trap_fork()



commit 6bba3128ca694ebc3e06b4e84e6c6562aa545f95
Author: Garrett Regier <garrettregier gmail com>
Date:   Tue Nov 12 22:44:15 2013 -0800

    Use g_test_trap_subprocess() instead of g_test_trap_fork()
    
    g_test_trap_fork() is deprecated.

 configure.ac           |    2 +-
 tests/libpeas/engine.c |   32 ++++++++++++++++++++------------
 2 files changed, 21 insertions(+), 13 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 6dbc244..d2b862b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -100,7 +100,7 @@ AC_SUBST(GIO_REQUIRED)
 AC_SUBST(INTROSPECTION_REQUIRED)
 
 AC_DEFINE(GLIB_VERSION_MIN_REQUIRED, GLIB_VERSION_2_32, [minimum glib version])
-AC_DEFINE(GLIB_VERSION_MAX_ALLOWED, GLIB_VERSION_2_32, [maximum glib version])
+AC_DEFINE(GLIB_VERSION_MAX_ALLOWED, GLIB_VERSION_2_38, [maximum glib version])
 
 dnl ================================================================
 dnl Build libpeas-gtk
diff --git a/tests/libpeas/engine.c b/tests/libpeas/engine.c
index c8f4848..da11183 100644
--- a/tests/libpeas/engine.c
+++ b/tests/libpeas/engine.c
@@ -427,25 +427,31 @@ test_engine_nonexistent_search_path (PeasEngine *engine)
   peas_engine_add_search_path (engine, "/nowhere", NULL);
 }
 
-
+#if GLIB_CHECK_VERSION (2, 38, 0)
 static void
 test_engine_shutdown (void)
 {
-  /* Should be able to shutdown multiple times */
-  peas_engine_shutdown ();
-  peas_engine_shutdown ();
-
-  /* Cannot create an engine because libpeas has been shutdown */
-  if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
-    {
-      peas_engine_new ();
-      exit (0);
-    }
+  g_test_trap_subprocess ("/engine/shutdown/subprocess", 0, 0);
   g_test_trap_assert_failed ();
   g_test_trap_assert_stderr ("*libpeas cannot create a plugin "
                               "engine as it has been shutdown*");
 }
 
+static void
+test_engine_shutdown_subprocess (PeasEngine *engine)
+{
+    testing_engine_free (engine);
+
+    /* Should be able to shutdown multiple times */
+    peas_engine_shutdown ();
+    peas_engine_shutdown ();
+
+    /* Cannot create an engine because libpeas has been shutdown */
+    engine = peas_engine_new ();
+    g_assert (engine == NULL);
+}
+#endif
+
 int
 main (int    argc,
       char **argv)
@@ -484,8 +490,10 @@ main (int    argc,
 
   TEST ("nonexistent-search-path", nonexistent_search_path);
 
-  /* MUST be last */
+#if GLIB_CHECK_VERSION (2, 38, 0)
   TEST_FUNC ("shutdown", shutdown);
+  TEST ("shutdown/subprocess", shutdown_subprocess);
+#endif
 
 #undef TEST
 


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