[libpeas] Fix the test suite to work on other operating systems



commit 1f7655890c7b38e0b172b2d9f350142675a3dc6c
Author: Garrett Regier <garrettregier gmail com>
Date:   Thu Dec 18 06:14:14 2014 -0800

    Fix the test suite to work on other operating systems
    
    Change the warnings so they can be checked properly in
    the tests without relying on OS specific messages.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=727380

 libpeas/peas-object-module.c      |   28 ++++++++++++++++------------
 tests/libpeas/engine.c            |    3 +--
 tests/libpeas/extension-c.c       |    2 +-
 tests/testing-util/testing-util.c |    2 +-
 4 files changed, 19 insertions(+), 16 deletions(-)
---
diff --git a/libpeas/peas-object-module.c b/libpeas/peas-object-module.c
index b556575..1f36ec7 100644
--- a/libpeas/peas-object-module.c
+++ b/libpeas/peas-object-module.c
@@ -90,11 +90,12 @@ peas_object_module_load (GTypeModule *gmodule)
   path = g_module_build_path (module->priv->path, module->priv->module_name);
   g_return_val_if_fail (path != NULL, FALSE);
 
-  /* g_module_build_path() will add G_MODULE_SUFFIX to the path, but otoh
-   * g_module_open() will only try to load the libtool archive if there is no
-   * suffix specified. So we remove G_MODULE_SUFFIX here (this allows
-   * uninstalled builds to load plugins as well, as there is only the .la file
-   * in the build directory) */
+  /* g_module_build_path() will add G_MODULE_SUFFIX to the path,
+   * however g_module_open() will only try to load the libtool archive
+   * if there is no suffix specified. So we remove G_MODULE_SUFFIX here
+   * which allows uninstalled builds to load plugins as well, as there
+   * is only the .la file in the build directory.
+   */
   if (G_MODULE_SUFFIX[0] != '\0' && g_str_has_suffix (path, "." G_MODULE_SUFFIX))
     path[strlen (path) - strlen (G_MODULE_SUFFIX) - 1] = '\0';
 
@@ -104,27 +105,30 @@ peas_object_module_load (GTypeModule *gmodule)
 
   if (module->priv->library == NULL)
     {
-      g_warning ("%s: %s", module->priv->module_name, g_module_error ());
+      g_warning ("Failed to load module '%s': %s",
+                 module->priv->module_name, g_module_error ());
 
       return FALSE;
     }
 
-  /* extract symbols from the lib */
+  /* Extract the required symbol from the library */
   if (!g_module_symbol (module->priv->library,
                         "peas_register_types",
-                        (void *) &module->priv->register_func))
+                        (gpointer) &module->priv->register_func))
     {
-      g_warning ("%s: %s", module->priv->module_name, g_module_error ());
+      g_warning ("Failed to get 'peas_register_types' for module '%s': %s",
+                 module->priv->module_name, g_module_error ());
       g_module_close (module->priv->library);
 
       return FALSE;
     }
 
-  /* symbol can still be NULL even though g_module_symbol
-   * returned TRUE */
+  /* The symbol can still be NULL even
+   * though g_module_symbol() returned TRUE
+   */
   if (module->priv->register_func == NULL)
     {
-      g_warning ("%s: Symbol 'peas_register_types' is not defined",
+      g_warning ("Invalid 'peas_register_types' in module '%s'",
                  module->priv->module_name);
       g_module_close (module->priv->library);
 
diff --git a/tests/libpeas/engine.c b/tests/libpeas/engine.c
index 0c429fd..68dff08 100644
--- a/tests/libpeas/engine.c
+++ b/tests/libpeas/engine.c
@@ -248,8 +248,7 @@ test_engine_not_loadable_plugin (PeasEngine *engine)
   GError *error = NULL;
   PeasPluginInfo *info;
 
-  testing_util_push_log_hook ("*libnot-loadable.so: cannot open shared "
-                              "object file: No such file or directory");
+  testing_util_push_log_hook ("Failed to load module 'not-loadable'*");
   testing_util_push_log_hook ("Error loading plugin 'not-loadable'");
 
   info = peas_engine_get_plugin_info (engine, "not-loadable");
diff --git a/tests/libpeas/extension-c.c b/tests/libpeas/extension-c.c
index ef82b9c..c450ec8 100644
--- a/tests/libpeas/extension-c.c
+++ b/tests/libpeas/extension-c.c
@@ -53,7 +53,7 @@ test_extension_c_nonexistent (PeasEngine *engine)
 {
   PeasPluginInfo *info;
 
-  testing_util_push_log_hook ("*extension-c-nonexistent*No such file*");
+  testing_util_push_log_hook ("Failed to load module 'extension-c-nonexistent'*");
   testing_util_push_log_hook ("Error loading plugin 'extension-c-nonexistent'");
 
   info = peas_engine_get_plugin_info (engine, "extension-c-nonexistent");
diff --git a/tests/testing-util/testing-util.c b/tests/testing-util/testing-util.c
index 3b98fe9..420310a 100644
--- a/tests/testing-util/testing-util.c
+++ b/tests/testing-util/testing-util.c
@@ -58,7 +58,7 @@ static GPrivate log_hooks_key = G_PRIVATE_INIT (log_hooks_private_notify);
  * Don't bother putting errors in here as GLib always aborts on errors.
  */
 static const gchar *allowed_patterns[] = {
-  "*lib*loader.so*cannot open shared object file: No such file or directory*"
+  "Failed to load module '*loader'*"
 };
 
 static void


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