[glib: 1/2] Fix test failures for static builds



commit 2718245dc28b11c71cb74be2aeb5c90f2f4a4f7b
Author: DDoSolitary <ddosolitary gmail com>
Date:   Mon Jul 15 11:01:04 2019 +0000

    Fix test failures for static builds
    
    The plugin modules in these tests get statically linked with a separate
    copy of GLib so they end up calling vfuncs in their own copy of GLib.
    
    Fixes #1648

 gio/tests/giomodule.c | 14 ++++++++++++++
 gio/tests/resources.c |  8 ++++++++
 meson.build           |  2 +-
 3 files changed, 23 insertions(+), 1 deletion(-)
---
diff --git a/gio/tests/giomodule.c b/gio/tests/giomodule.c
index 61746d3d1..b4923eeef 100644
--- a/gio/tests/giomodule.c
+++ b/gio/tests/giomodule.c
@@ -21,6 +21,7 @@
  */
 
 #include <gio/gio.h>
+#include <glibconfig.h>
 
 #ifdef _MSC_VER
 # define MODULE_FILENAME_PREFIX ""
@@ -82,6 +83,13 @@ test_extension_point (void)
 static void
 test_module_scan_all (void)
 {
+#ifdef GLIB_STATIC_COMPILATION
+  /* The plugin module is statically linked with a separate copy
+   * of GLib so g_io_extension_point_implement won't work. */
+  g_test_skip ("GIOExtensionPoint with dynamic modules isn't supported in static builds.");
+  return;
+#endif
+
   if (g_test_subprocess ())
     {
       GIOExtensionPoint *ep;
@@ -104,6 +112,12 @@ test_module_scan_all (void)
 static void
 test_module_scan_all_with_scope (void)
 {
+#ifdef GLIB_STATIC_COMPILATION
+  /* Disabled for the same reason as test_module_scan_all. */
+  g_test_skip ("GIOExtensionPoint with dynamic modules isn't supported in static builds.");
+  return;
+#endif
+
   if (g_test_subprocess ())
     {
       GIOExtensionPoint *ep;
diff --git a/gio/tests/resources.c b/gio/tests/resources.c
index 5cacda16a..c44d21485 100644
--- a/gio/tests/resources.c
+++ b/gio/tests/resources.c
@@ -18,6 +18,7 @@
 
 #include <string.h>
 #include <gio/gio.h>
+#include <glibconfig.h>
 #include "gconstructor.h"
 #include "test_resources2.h"
 #include "digit_test_resources.h"
@@ -644,6 +645,13 @@ test_resource_module (void)
   GBytes *data;
   GError *error;
 
+#ifdef GLIB_STATIC_COMPILATION
+  /* The resource module is statically linked with a separate copy
+   * of a GLib so g_static_resource_init won't work as expected. */
+  g_test_skip ("Resource modules aren't supported in static builds.");
+  return;
+#endif
+
   if (g_module_supported ())
     {
       module = g_io_module_new (g_test_get_filename (G_TEST_BUILT,
diff --git a/meson.build b/meson.build
index 232cd6c87..416c927cc 100644
--- a/meson.build
+++ b/meson.build
@@ -183,7 +183,7 @@ if get_option('default_library') != 'static'
   endif
 endif
 
-if host_system == 'windows' and get_option('default_library') == 'static'
+if get_option('default_library') == 'static'
     glibconfig_conf.set('GLIB_STATIC_COMPILATION', '1')
     glibconfig_conf.set('GOBJECT_STATIC_COMPILATION', '1')
 endif


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