[libpeas] No longer use a GHashTable for storing the plugin loaders
- From: Garrett Regier <gregier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libpeas] No longer use a GHashTable for storing the plugin loaders
- Date: Tue, 4 Nov 2014 14:08:01 +0000 (UTC)
commit 1b5f91bf344475ba1f825c9317799c30b7694324
Author: Garrett Regier <garrett regier riftio com>
Date: Fri Oct 31 03:19:14 2014 -0700
No longer use a GHashTable for storing the plugin loaders
Replace with a static array and functions to convert
from a loader name to an id and back. Also, warn if an
unknown loader is given to peas_engine_enable_loader()
or specified in a .plugin file.
libpeas/peas-engine.c | 197 +++++++++-----------
libpeas/peas-engine.h | 2 +-
libpeas/peas-plugin-info-priv.h | 2 +-
libpeas/peas-plugin-info.c | 34 +++--
libpeas/peas-utils.c | 40 ++++
libpeas/peas-utils.h | 6 +
tests/libpeas/engine.c | 40 +----
tests/libpeas/plugins/Makefile.am | 6 +-
tests/libpeas/plugins/disabled-loader.plugin | 7 -
tests/libpeas/plugins/extension-python/Makefile.am | 12 +-
...-py.gschema.xml => extension-py.gschema.xml.in} | 0
...{extension-py.plugin => extension-py.plugin.in} | 0
.../{extension-py.py => extension-py.py.in} | 0
tests/libpeas/plugins/invalid-loader.plugin | 7 -
tests/libpeas/plugins/nonexistent-loader.plugin | 7 -
tests/libpeas/plugins/unkown-loader.plugin | 7 +
tests/libpeas/testing/testing.c | 10 +-
17 files changed, 181 insertions(+), 196 deletions(-)
---
diff --git a/libpeas/peas-engine.c b/libpeas/peas-engine.c
index 37fc12b..249b357 100644
--- a/libpeas/peas-engine.c
+++ b/libpeas/peas-engine.c
@@ -59,10 +59,6 @@
**/
G_DEFINE_TYPE (PeasEngine, peas_engine, G_TYPE_OBJECT)
-static PeasEngine *default_engine = NULL;
-static gboolean shutdown = FALSE;
-static GHashTable *loaders = NULL;
-
/* Signals */
enum {
LOAD_PLUGIN,
@@ -84,6 +80,9 @@ static GParamSpec *properties[N_PROPERTIES] = { NULL };
typedef struct _LoaderInfo {
PeasPluginLoader *loader;
PeasObjectModule *module;
+
+ guint enabled : 1;
+ guint failed : 1;
} LoaderInfo;
typedef struct _SearchPath {
@@ -99,6 +98,10 @@ struct _PeasEnginePrivate {
guint in_dispose : 1;
};
+static PeasEngine *default_engine = NULL;
+static gboolean shutdown = FALSE;
+static LoaderInfo loaders[PEAS_UTILS_N_LOADERS];
+
static void peas_engine_load_plugin_real (PeasEngine *engine,
PeasPluginInfo *info);
static void peas_engine_unload_plugin_real (PeasEngine *engine,
@@ -290,44 +293,6 @@ peas_engine_prepend_search_path (PeasEngine *engine,
peas_engine_insert_search_path (engine, 0, module_dir, data_dir);
}
-static guint
-hash_lowercase (gconstpointer data)
-{
- gchar *lowercase;
- guint ret;
-
- lowercase = g_ascii_strdown ((const gchar *) data, -1);
- ret = g_str_hash (lowercase);
- g_free (lowercase);
-
- return ret;
-}
-
-static gboolean
-equal_lowercase (const gchar *a,
- const gchar *b)
-{
- return g_ascii_strcasecmp (a, b) == 0;
-}
-
-static void
-loader_destroy (LoaderInfo *info)
-{
- if (!info)
- return;
-
- if (info->loader)
- {
- g_object_add_weak_pointer (G_OBJECT (info->loader),
- (gpointer *) &info->loader);
-
- g_object_unref (info->loader);
- g_assert (info->loader == NULL);
- }
-
- g_free (info);
-}
-
static void
peas_engine_init (PeasEngine *engine)
{
@@ -348,15 +313,6 @@ peas_engine_init (PeasEngine *engine)
engine->priv->in_dispose = FALSE;
}
-
-static void
-loader_garbage_collect (const gchar *id,
- LoaderInfo *info)
-{
- if (info != NULL && info->loader != NULL)
- peas_plugin_loader_garbage_collect (info->loader);
-}
-
/**
* peas_engine_garbage_collect:
* @engine: A #PeasEngine.
@@ -369,11 +325,15 @@ loader_garbage_collect (const gchar *id,
void
peas_engine_garbage_collect (PeasEngine *engine)
{
+ gint i;
+
g_return_if_fail (PEAS_IS_ENGINE (engine));
- g_hash_table_foreach (loaders,
- (GHFunc) loader_garbage_collect,
- NULL);
+ for (i = 0; i < G_N_ELEMENTS (loaders); ++i)
+ {
+ if (loaders[i].loader != NULL)
+ peas_plugin_loader_garbage_collect (loaders[i].loader);
+ }
}
static GObject *
@@ -604,14 +564,8 @@ peas_engine_class_init (PeasEngineClass *klass)
* global init function for libpeas. */
peas_debug_init ();
- /* mapping from loadername -> loader object */
- loaders = g_hash_table_new_full (hash_lowercase,
- (GEqualFunc) equal_lowercase,
- (GDestroyNotify) g_free,
- (GDestroyNotify) loader_destroy);
-
/* The C plugin loader is always enabled */
- g_hash_table_insert (loaders, g_strdup ("C"), g_new0 (LoaderInfo, 1));
+ loaders[peas_utils_get_loader_id ("C")].enabled = TRUE;
}
static PeasObjectModule *
@@ -632,35 +586,33 @@ load_module (const gchar *module_name,
}
static PeasPluginLoader *
-get_plugin_loader (PeasEngine *engine,
- PeasPluginInfo *info)
+get_plugin_loader (PeasEngine *engine,
+ gint loader_id)
{
LoaderInfo *loader_info;
- gchar *loader_id, *module_name, *module_dir;
+ const gchar *loader_name;
+ gchar *module_name, *module_dir;
- loader_info = (LoaderInfo *) g_hash_table_lookup (loaders, info->loader);
+ loader_info = &loaders[loader_id];
- /* The loader has not been enabled. */
- if (loader_info == NULL)
+ if (!loader_info->enabled)
{
g_warning ("The '%s' plugin loader has not been enabled",
- info->loader);
+ peas_utils_get_loader_from_id (loader_id));
return NULL;
}
- /* The loader has already been loaded. */
- if (loader_info->loader != NULL)
+ if (loader_info->loader != NULL || loader_info->failed)
return loader_info->loader;
- /* Create the default C plugin loader. */
- if (g_ascii_strcasecmp (info->loader, "C") == 0)
+ if (peas_utils_get_loader_id ("C") == loader_id)
{
loader_info->loader = peas_plugin_loader_c_new ();
return loader_info->loader;
}
- loader_id = g_ascii_strdown (info->loader, -1);
- module_name = g_strconcat (loader_id, "loader", NULL);
+ loader_name = peas_utils_get_loader_from_id (loader_id);
+ module_name = g_strconcat (loader_name, "loader", NULL);
module_dir = peas_dirs_get_plugin_loaders_dir ();
loader_info->module = load_module (module_name, module_dir);
@@ -669,21 +621,20 @@ get_plugin_loader (PeasEngine *engine,
{
gchar *tmp = module_dir;
- module_dir = g_build_filename (module_dir, loader_id, NULL);
+ module_dir = g_build_filename (module_dir, loader_name, NULL);
loader_info->module = load_module (module_name, module_dir);
g_free (tmp);
+ }
- if (loader_info->module == NULL)
- {
- g_warning ("Could not load plugin loader '%s'", info->loader);
+ g_free (module_dir);
+ g_free (module_name);
- g_free (module_dir);
- g_free (module_name);
- g_free (loader_id);
- g_hash_table_insert (loaders, g_strdup (info->loader), NULL);
- return NULL;
- }
+ if (loader_info->module == NULL)
+ {
+ g_warning ("Could not load plugin loader '%s'", loader_name);
+ loader_info->failed = TRUE;
+ return NULL;
}
loader_info->loader = PEAS_PLUGIN_LOADER (
@@ -691,19 +642,18 @@ get_plugin_loader (PeasEngine *engine,
PEAS_TYPE_PLUGIN_LOADER,
0, NULL));
- g_type_module_unuse (G_TYPE_MODULE (loader_info->module));
- g_free (module_dir);
- g_free (module_name);
- g_free (loader_id);
+ /* Don't bother unloading the loader's
+ * GTypeModule as it is always resident
+ */
if (loader_info->loader == NULL ||
!peas_plugin_loader_initialize (loader_info->loader))
{
g_warning ("Loader '%s' is not a valid PeasPluginLoader instance",
- info->loader);
+ loader_name);
- /* This will cause the loader to be unreffed if it exists */
- g_hash_table_insert (loaders, g_strdup (info->loader), NULL);
+ loader_info->failed = TRUE;
+ g_clear_object (&loader_info->loader);
return NULL;
}
@@ -713,7 +663,7 @@ get_plugin_loader (PeasEngine *engine,
/**
* peas_engine_enable_loader:
* @engine: A #PeasEngine.
- * @loader_id: The id of the loader to enable.
+ * @loader_name: The name of the loader to enable.
*
* Enable a loader, enables a loader for plugins.
* The C plugin loader is always enabled. The other plugin
@@ -735,31 +685,38 @@ get_plugin_loader (PeasEngine *engine,
**/
void
peas_engine_enable_loader (PeasEngine *engine,
- const gchar *loader_id)
+ const gchar *loader_name)
{
+ gint loader_id;
+
g_return_if_fail (PEAS_IS_ENGINE (engine));
- g_return_if_fail (loader_id != NULL && *loader_id != '\0');
+ g_return_if_fail (loader_name != NULL && *loader_name != '\0');
+
+ loader_id = peas_utils_get_loader_id (loader_name);
+
+ if (loader_id == -1)
+ {
+ g_warning ("Failed to enable unknown plugin loader '%s'", loader_name);
+ return;
+ }
- if (g_hash_table_lookup_extended (loaders, loader_id, NULL, NULL))
+ if (loaders[loader_id].enabled)
return;
/* The demo and some tests need to load multiple loaders */
if (g_getenv ("PEAS_ALLOW_ALL_LOADERS") == NULL)
{
- static const gchar *plugin_loader_ids[] = {"python", "python3"};
gint i;
+ static const gchar *other_loaders[] = {"python", "python3"};
- for (i = 0; i < G_N_ELEMENTS (plugin_loader_ids); ++i)
+ for (i = 0; i < G_N_ELEMENTS (other_loaders); ++i)
{
- if (g_ascii_strcasecmp (loader_id, plugin_loader_ids[i]) == 0)
- continue;
-
- if (g_hash_table_lookup_extended (loaders, plugin_loader_ids[i],
- NULL, NULL))
+ if (loaders[peas_utils_get_loader_id (other_loaders[i])].enabled)
{
g_warning ("Cannot enable plugin loader '%s' as the "
"'%s' plugin loader has already been enabled.",
- loader_id, plugin_loader_ids[i]);
+ loader_name, other_loaders[i]);
+ loaders[loader_id].failed = TRUE;
return;
}
}
@@ -768,7 +725,7 @@ peas_engine_enable_loader (PeasEngine *engine,
/* We do not load the plugin loader immediately and instead
* load it in get_plugin_loader() so that it is loaded lazily.
*/
- g_hash_table_insert (loaders, g_strdup (loader_id), g_new0 (LoaderInfo, 1));
+ loaders[loader_id].enabled = TRUE;
}
/**
@@ -869,7 +826,7 @@ peas_engine_load_plugin_real (PeasEngine *engine,
}
}
- loader = get_plugin_loader (engine, info);
+ loader = get_plugin_loader (engine, info->loader_id);
if (loader == NULL)
{
@@ -878,7 +835,7 @@ peas_engine_load_plugin_real (PeasEngine *engine,
PEAS_PLUGIN_INFO_ERROR,
PEAS_PLUGIN_INFO_ERROR_LOADER_NOT_FOUND,
_("Plugin loader '%s' was not found"),
- info->loader);
+ peas_utils_get_loader_from_id (info->loader_id));
goto error;
}
@@ -964,7 +921,7 @@ peas_engine_unload_plugin_real (PeasEngine *engine,
}
/* find the loader and tell it to gc and unload the plugin */
- loader = get_plugin_loader (engine, info);
+ loader = get_plugin_loader (engine, info->loader_id);
peas_plugin_loader_garbage_collect (loader);
peas_plugin_loader_unload (loader, info);
@@ -1030,7 +987,7 @@ peas_engine_provides_extension (PeasEngine *engine,
if (!peas_plugin_info_is_loaded (info))
return FALSE;
- loader = get_plugin_loader (engine, info);
+ loader = get_plugin_loader (engine, info->loader_id);
return peas_plugin_loader_provides_extension (loader, info, extension_type);
}
@@ -1067,7 +1024,7 @@ peas_engine_create_extensionv (PeasEngine *engine,
g_return_val_if_fail (peas_plugin_info_is_loaded (info), NULL);
g_return_val_if_fail (G_TYPE_IS_INTERFACE (extension_type), FALSE);
- loader = get_plugin_loader (engine, info);
+ loader = get_plugin_loader (engine, info->loader_id);
extension = peas_plugin_loader_create_extension (loader, info, extension_type,
n_parameters, parameters);
@@ -1312,7 +1269,7 @@ peas_engine_get_default (void)
return default_engine;
}
-/*
+/* < private >
* peas_engine_shutdown:
*
* Frees memory shared by PeasEngines.
@@ -1321,14 +1278,28 @@ peas_engine_get_default (void)
void
peas_engine_shutdown (void)
{
+ gint i;
+
if (shutdown)
return;
shutdown = TRUE;
- if (loaders != NULL)
+ for (i = 0; i < G_N_ELEMENTS (loaders); ++i)
{
- g_hash_table_destroy (loaders);
- loaders = NULL;
+ LoaderInfo *loader_info = &loaders[i];
+
+ if (loader_info->loader != NULL)
+ {
+ g_object_add_weak_pointer (G_OBJECT (loader_info->loader),
+ (gpointer *) &loader_info->loader);
+
+ g_object_unref (loader_info->loader);
+ g_assert (loader_info->loader == NULL);
+ }
+
+ loader_info->module = NULL;
+ loader_info->enabled = FALSE;
+ loader_info->failed = TRUE;
}
}
diff --git a/libpeas/peas-engine.h b/libpeas/peas-engine.h
index a72e930..8d23347 100644
--- a/libpeas/peas-engine.h
+++ b/libpeas/peas-engine.h
@@ -86,7 +86,7 @@ void peas_engine_prepend_search_path (PeasEngine *engine,
/* plugin management */
void peas_engine_enable_loader (PeasEngine *engine,
- const gchar *loader_id);
+ const gchar *loader_name);
void peas_engine_rescan_plugins (PeasEngine *engine);
const GList *peas_engine_get_plugin_list (PeasEngine *engine);
gchar **peas_engine_get_loaded_plugins (PeasEngine *engine);
diff --git a/libpeas/peas-plugin-info-priv.h b/libpeas/peas-plugin-info-priv.h
index e67e9a5..60c9096 100644
--- a/libpeas/peas-plugin-info-priv.h
+++ b/libpeas/peas-plugin-info-priv.h
@@ -32,8 +32,8 @@ struct _PeasPluginInfo {
gchar *module_dir;
gchar *data_dir;
+ gint loader_id;
gchar *module_name;
- gchar *loader;
gchar **dependencies;
gchar *name;
diff --git a/libpeas/peas-plugin-info.c b/libpeas/peas-plugin-info.c
index fc5fd01..8124540 100644
--- a/libpeas/peas-plugin-info.c
+++ b/libpeas/peas-plugin-info.c
@@ -29,6 +29,7 @@
#include "peas-i18n.h"
#include "peas-plugin-info-priv.h"
+#include "peas-utils.h"
#ifdef G_OS_WIN32
#define OS_HELP_KEY "Help-Windows"
@@ -88,7 +89,6 @@ _peas_plugin_info_unref (PeasPluginInfo *info)
g_free (info->icon_name);
g_free (info->website);
g_free (info->copyright);
- g_free (info->loader);
g_free (info->version);
g_free (info->help_uri);
g_strfreev (info->authors);
@@ -134,6 +134,7 @@ _peas_plugin_info_new (const gchar *filename,
const gchar *data_dir)
{
gsize i;
+ gchar *loader = NULL;
gchar **strv, **keys;
PeasPluginInfo *info;
GKeyFile *plugin_file;
@@ -173,6 +174,25 @@ _peas_plugin_info_new (const gchar *filename,
goto error;
}
+ /* Get the loader for this plugin */
+ loader = g_key_file_get_string (plugin_file, "Plugin", "Loader", NULL);
+ if (loader == NULL || *loader == '\0')
+ {
+ /* Default to the C loader */
+ info->loader_id = peas_utils_get_loader_id ("C");
+ }
+ else
+ {
+ info->loader_id = peas_utils_get_loader_id (loader);
+
+ if (info->loader_id == -1)
+ {
+ g_warning ("Unkown 'Loader' in '[Plugin]' section in '%s': %s",
+ filename, loader);
+ goto error;
+ }
+ }
+
/* Get the dependency list */
info->dependencies = g_key_file_get_string_list (plugin_file,
"Plugin",
@@ -180,17 +200,6 @@ _peas_plugin_info_new (const gchar *filename,
if (info->dependencies == NULL)
info->dependencies = g_new0 (gchar *, 1);
- /* Get the loader for this plugin */
- info->loader = g_key_file_get_string (plugin_file, "Plugin",
- "Loader", NULL);
- if (info->loader == NULL || *info->loader == '\0')
- {
- g_free (info->loader);
-
- /* default to the C loader */
- info->loader = g_strdup ("C");
- }
-
/* Get Description */
info->desc = g_key_file_get_locale_string (plugin_file, "Plugin",
"Description", NULL, NULL);
@@ -271,6 +280,7 @@ _peas_plugin_info_new (const gchar *filename,
error:
+ g_free (loader);
g_free (info->module_name);
g_free (info->name);
g_free (info);
diff --git a/libpeas/peas-utils.c b/libpeas/peas-utils.c
index 5e738c9..21668f8 100644
--- a/libpeas/peas-utils.c
+++ b/libpeas/peas-utils.c
@@ -29,6 +29,9 @@
#include "peas-utils.h"
+static const gchar *all_plugin_loaders[] = {"c", "python", "python3"};
+G_STATIC_ASSERT (G_N_ELEMENTS (all_plugin_loaders) == PEAS_UTILS_N_LOADERS);
+
static void
add_all_interfaces (GType iface_type,
GPtrArray *type_structs)
@@ -144,3 +147,40 @@ error:
return FALSE;
}
+
+gint
+peas_utils_get_loader_id (const gchar *loader)
+{
+ gint i;
+ gsize len;
+ gchar lowercase[32];
+
+ len = strlen (loader);
+
+ /* No loader has a name that long */
+ if (len >= G_N_ELEMENTS (lowercase))
+ return -1;
+
+ for (i = 0; i < len; ++i)
+ lowercase[i] = g_ascii_tolower (loader[i]);
+
+ lowercase[len] = '\0';
+
+ for (i = 0; i < G_N_ELEMENTS (all_plugin_loaders); ++i)
+ {
+ if (g_strcmp0 (lowercase, all_plugin_loaders[i]) == 0)
+ return i;
+ }
+
+ return -1;
+}
+
+const gchar *
+peas_utils_get_loader_from_id (gint loader_id)
+{
+ g_return_val_if_fail (loader_id >= 0, NULL);
+ g_return_val_if_fail (loader_id < G_N_ELEMENTS (all_plugin_loaders), NULL);
+
+ return all_plugin_loaders[loader_id];
+}
+
diff --git a/libpeas/peas-utils.h b/libpeas/peas-utils.h
index df852b2..e7f55de 100644
--- a/libpeas/peas-utils.h
+++ b/libpeas/peas-utils.h
@@ -24,10 +24,16 @@
#include <glib-object.h>
+#define PEAS_UTILS_N_LOADERS 3
+
gboolean peas_utils_valist_to_parameter_list (GType iface_type,
const gchar *first_property,
va_list var_args,
GParameter **params,
guint *n_params);
+gint peas_utils_get_loader_id (const gchar *loader) G_GNUC_CONST;
+const gchar *
+ peas_utils_get_loader_from_id (gint loader_id) G_GNUC_CONST;
+
#endif /* __PEAS_UTILS_H__ */
diff --git a/tests/libpeas/engine.c b/tests/libpeas/engine.c
index 1663ea7..0c429fd 100644
--- a/tests/libpeas/engine.c
+++ b/tests/libpeas/engine.c
@@ -381,43 +381,12 @@ test_engine_loaded_plugins (PeasEngine *engine)
}
static void
-test_engine_nonexistent_loader (PeasEngine *engine)
+test_engine_enable_unkown_loader (PeasEngine *engine)
{
- GError *error = NULL;
- PeasPluginInfo *info;
+ testing_util_push_log_hook ("Failed to enable unknown "
+ "plugin loader 'does-not-exist'");
- testing_util_push_log_hook ("Could not load plugin loader 'does-not-exist'*");
-
- info = peas_engine_get_plugin_info (engine, "nonexistent-loader");
peas_engine_enable_loader (engine, "does-not-exist");
-
- g_assert (!peas_engine_load_plugin (engine, info));
- g_assert (!peas_plugin_info_is_loaded (info));
- g_assert (!peas_plugin_info_is_available (info, &error));
- g_assert_error (error, PEAS_PLUGIN_INFO_ERROR,
- PEAS_PLUGIN_INFO_ERROR_LOADER_NOT_FOUND);
-
- g_error_free (error);
-}
-
-static void
-test_engine_disabled_loader (PeasEngine *engine)
-{
- PeasPluginInfo *info;
- GError *error = NULL;
-
- testing_util_push_log_hook ("The 'disabled' plugin "
- "loader has not been enabled*");
-
- info = peas_engine_get_plugin_info (engine, "disabled-loader");
-
- g_assert (!peas_engine_load_plugin (engine, info));
- g_assert (!peas_plugin_info_is_loaded (info));
- g_assert (!peas_plugin_info_is_available (info, &error));
- g_assert_error (error, PEAS_PLUGIN_INFO_ERROR,
- PEAS_PLUGIN_INFO_ERROR_LOADER_NOT_FOUND);
-
- g_error_free (error);
}
static void
@@ -490,8 +459,7 @@ main (int argc,
TEST ("loaded-plugins", loaded_plugins);
- TEST ("nonexistent-loader", nonexistent_loader);
- TEST ("disabled-loader", disabled_loader);
+ TEST ("enable-unkown-loader", enable_unkown_loader);
TEST ("enable-loader-multiple-times", enable_loader_multiple_times);
TEST ("nonexistent-search-path", nonexistent_search_path);
diff --git a/tests/libpeas/plugins/Makefile.am b/tests/libpeas/plugins/Makefile.am
index 5e5b685..db49e17 100644
--- a/tests/libpeas/plugins/Makefile.am
+++ b/tests/libpeas/plugins/Makefile.am
@@ -11,17 +11,15 @@ endif
endif
noinst_PLUGIN = \
- disabled-loader.plugin \
extension-c-nonexistent.plugin \
extension-python-nonexistent.plugin \
extension-python3-nonexistent.plugin \
info-missing-module.plugin \
info-missing-name.plugin \
invalid.plugin \
- invalid-loader.plugin \
nonexistent-dep.plugin \
- nonexistent-loader.plugin \
not-loadable.plugin \
- os-dependant-help.plugin
+ os-dependant-help.plugin \
+ unkown-loader.plugin
EXTRA_DIST = $(noinst_PLUGIN)
diff --git a/tests/libpeas/plugins/extension-python/Makefile.am
b/tests/libpeas/plugins/extension-python/Makefile.am
index 31a34f5..6cb7fde 100644
--- a/tests/libpeas/plugins/extension-python/Makefile.am
+++ b/tests/libpeas/plugins/extension-python/Makefile.am
@@ -11,21 +11,21 @@ noinst_DATA = \
extension-py.%:
test -e $@
-extension-python.gschema.xml extension-python3.gschema.xml: extension-py.gschema.xml
+extension-python.gschema.xml extension-python3.gschema.xml: extension-py.gschema.xml.in
$(AM_V_GEN) cp $< $@ && \
$(SED) -i -e 's%PY_LOADER%$(@:extension-%.gschema.xml=%)%g' $@
-extension-python.py extension-python3.py: extension-py.py
+extension-python.py extension-python3.py: extension-py.py.in
$(AM_V_GEN) $(LN_S) $< $@
-extension-python.plugin extension-python3.plugin: extension-py.plugin
+extension-python.plugin extension-python3.plugin: extension-py.plugin.in
$(AM_V_GEN) cp $< $@ && \
$(SED) -i -e 's%PY_LOADER%$(@:extension-%.plugin=%)%g' $@
EXTRA_DIST = \
- extension-py.gschema.xml \
- extension-py.plugin \
- extension-py.py
+ extension-py.gschema.xml.in \
+ extension-py.plugin.in \
+ extension-py.py.in
CLEANFILES = $(noinst_DATA)
DISTCLEANFILES = $(noinst_DATA)
diff --git a/tests/libpeas/plugins/extension-python/extension-py.gschema.xml
b/tests/libpeas/plugins/extension-python/extension-py.gschema.xml.in
similarity index 100%
rename from tests/libpeas/plugins/extension-python/extension-py.gschema.xml
rename to tests/libpeas/plugins/extension-python/extension-py.gschema.xml.in
diff --git a/tests/libpeas/plugins/extension-python/extension-py.plugin
b/tests/libpeas/plugins/extension-python/extension-py.plugin.in
similarity index 100%
rename from tests/libpeas/plugins/extension-python/extension-py.plugin
rename to tests/libpeas/plugins/extension-python/extension-py.plugin.in
diff --git a/tests/libpeas/plugins/extension-python/extension-py.py
b/tests/libpeas/plugins/extension-python/extension-py.py.in
similarity index 100%
rename from tests/libpeas/plugins/extension-python/extension-py.py
rename to tests/libpeas/plugins/extension-python/extension-py.py.in
diff --git a/tests/libpeas/plugins/unkown-loader.plugin b/tests/libpeas/plugins/unkown-loader.plugin
new file mode 100644
index 0000000..4b32063
--- /dev/null
+++ b/tests/libpeas/plugins/unkown-loader.plugin
@@ -0,0 +1,7 @@
+[Plugin]
+Module=unkown-loader
+Loader=does-not-exist
+Name=Unkown Loader
+Description=This plugin has an unkown loader.
+Authors=Garrett Regier
+Copyright=Copyright © 2011 Garrett Regier
diff --git a/tests/libpeas/testing/testing.c b/tests/libpeas/testing/testing.c
index 0e29c09..aeb387e 100644
--- a/tests/libpeas/testing/testing.c
+++ b/tests/libpeas/testing/testing.c
@@ -62,12 +62,18 @@ testing_engine_new (void)
testing_util_push_log_hook ("*Bad plugin file *invalid.plugin*");
testing_util_push_log_hook ("*Error loading *invalid.plugin*");
- testing_util_push_log_hook ("*Could not find 'Module' in *info-missing-module.plugin*");
+ testing_util_push_log_hook ("*Could not find 'Module' in "
+ "*info-missing-module.plugin*");
testing_util_push_log_hook ("*Error loading *info-missing-module.plugin*");
- testing_util_push_log_hook ("*Could not find 'Name' in *info-missing-name.plugin*");
+ testing_util_push_log_hook ("*Could not find 'Name' in "
+ "*info-missing-name.plugin*");
testing_util_push_log_hook ("*Error loading *info-missing-name.plugin*");
+ testing_util_push_log_hook ("*Unkown 'Loader' in "
+ "*unkown-loader.plugin* does-not-exist");
+ testing_util_push_log_hook ("*Error loading *unkown-loader.plugin*");
+
/* Must be after pushing log hooks */
engine = testing_util_engine_new ();
peas_engine_add_search_path (engine, BUILDDIR "/tests/libpeas/plugins",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]