summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarrett Regier <garrettregier@gmail.com>2011-09-18 05:48:37 -0700
committerGarrett Regier <garrettregier@gmail.com>2011-09-18 07:09:56 -0700
commit01e5bfdf3719adfc4bdf311c3d4145c811de8feb (patch)
treef84547f739616834bb09f5cef958e12998489434
parent60abcaf17cbca040c7685736993e68e0e3567cc6 (diff)
downloadlibpeas-01e5bfdf3719adfc4bdf311c3d4145c811de8feb.tar.gz
Adds tests for a nonexistent plugin for all loaders
This also fixes the Seed loader so it does not seg fault.
-rw-r--r--loaders/seed/peas-plugin-loader-seed.c20
-rw-r--r--tests/libpeas/extension-c.c15
-rw-r--r--tests/libpeas/extension-gjs.c14
-rw-r--r--tests/libpeas/extension-python.c13
-rw-r--r--tests/libpeas/extension-seed.c14
-rw-r--r--tests/libpeas/plugins/Makefile.am20
-rw-r--r--tests/libpeas/plugins/extension-c-nonexistent.plugin8
-rw-r--r--tests/libpeas/plugins/extension-gjs-nonexistent.plugin9
-rw-r--r--tests/libpeas/plugins/extension-python-nonexistent.plugin9
-rw-r--r--tests/libpeas/plugins/extension-seed-nonexistent.plugin9
10 files changed, 118 insertions, 13 deletions
diff --git a/loaders/seed/peas-plugin-loader-seed.c b/loaders/seed/peas-plugin-loader-seed.c
index 44b8ac6..9c3fc0a 100644
--- a/loaders/seed/peas-plugin-loader-seed.c
+++ b/loaders/seed/peas-plugin-loader-seed.c
@@ -39,23 +39,29 @@ typedef struct {
static SeedEngine *seed = NULL;
static gchar *
-get_script_for_plugin_info (PeasPluginInfo *info,
- SeedContext context)
+get_script_for_plugin_info (PeasPluginInfo *info)
{
gchar *basename;
gchar *filename;
gchar *script = NULL;
+ GError *error = NULL;
basename = g_strconcat (peas_plugin_info_get_module_name (info), ".js", NULL);
filename = g_build_filename (peas_plugin_info_get_module_dir (info), basename, NULL);
g_debug ("Seed script filename is '%s'", filename);
- g_file_get_contents (filename, &script, NULL, NULL);
+ g_file_get_contents (filename, &script, NULL, &error);
g_free (basename);
g_free (filename);
+ if (error != NULL)
+ {
+ g_warning ("Error: %s", error->message);
+ g_error_free (error);
+ }
+
return script;
}
@@ -70,12 +76,16 @@ peas_plugin_loader_seed_load (PeasPluginLoader *loader,
SeedObject global, extensions;
SeedInfo *sinfo;
+ script = get_script_for_plugin_info (info);
+
+ if (script == NULL)
+ return FALSE;
+
context = seed_context_create (seed->group, NULL);
seed_prepare_global_context (context);
- script = get_script_for_plugin_info (info, context);
-
seed_simple_evaluate (context, script, &exc);
+
g_free (script);
if (exc)
diff --git a/tests/libpeas/extension-c.c b/tests/libpeas/extension-c.c
index 5338b86..ec9f6f9 100644
--- a/tests/libpeas/extension-c.c
+++ b/tests/libpeas/extension-c.c
@@ -73,6 +73,20 @@ test_extension_c_plugin_info (PeasEngine *engine)
g_object_unref (extension);
}
+static void
+test_extension_c_nonexistent (PeasEngine *engine)
+{
+ PeasPluginInfo *info;
+
+ testing_util_push_log_hook ("*extension-c-nonexistent*No such file*");
+ testing_util_push_log_hook ("Could not load*'extension-c-nonexistent'");
+ testing_util_push_log_hook ("Error loading plugin 'extension-c-nonexistent'");
+
+ info = peas_engine_get_plugin_info (engine, "extension-c-nonexistent");
+
+ g_assert (!peas_engine_load_plugin (engine, info));
+}
+
int
main (int argc,
char *argv[])
@@ -84,6 +98,7 @@ main (int argc,
EXTENSION_TEST (c, "instance-refcount", instance_refcount);
EXTENSION_TEST (c, "plugin-info", plugin_info);
+ EXTENSION_TEST (c, "nonexistent", nonexistent);
return testing_run_tests ();
}
diff --git a/tests/libpeas/extension-gjs.c b/tests/libpeas/extension-gjs.c
index 54efd53..963a7e0 100644
--- a/tests/libpeas/extension-gjs.c
+++ b/tests/libpeas/extension-gjs.c
@@ -64,6 +64,19 @@ test_extension_gjs_plugin_info (PeasEngine *engine)
g_object_unref (extension);
}
+static void
+test_extension_gjs_nonexistent (PeasEngine *engine)
+{
+ PeasPluginInfo *info;
+
+ testing_util_push_log_hook ("*Failed to open *extension-gjs-nonexistent.js*");
+ testing_util_push_log_hook ("Error loading plugin 'extension-gjs-nonexistent'");
+
+ info = peas_engine_get_plugin_info (engine, "extension-gjs-nonexistent");
+
+ g_assert (!peas_engine_load_plugin (engine, info));
+}
+
int
main (int argc,
char *argv[])
@@ -75,6 +88,7 @@ main (int argc,
EXTENSION_TESTS (gjs);
EXTENSION_TEST (gjs, "plugin-info", plugin_info);
+ EXTENSION_TEST (gjs, "nonexistent", nonexistent);
return testing_run_tests ();
}
diff --git a/tests/libpeas/extension-python.c b/tests/libpeas/extension-python.c
index 8dd37fe..e40a5cf 100644
--- a/tests/libpeas/extension-python.c
+++ b/tests/libpeas/extension-python.c
@@ -128,6 +128,18 @@ test_extension_python_plugin_info (PeasEngine *engine)
g_object_unref (extension);
}
+static void
+test_extension_python_nonexistent (PeasEngine *engine)
+{
+ PeasPluginInfo *info;
+
+ testing_util_push_log_hook ("Error loading plugin 'extension-python-nonexistent'");
+
+ info = peas_engine_get_plugin_info (engine, "extension-python-nonexistent");
+
+ g_assert (!peas_engine_load_plugin (engine, info));
+}
+
int
main (int argc,
char *argv[])
@@ -140,6 +152,7 @@ main (int argc,
EXTENSION_TEST (python, "instance-refcount", instance_refcount);
EXTENSION_TEST (python, "activatable-subject-refcount", activatable_subject_refcount);
EXTENSION_TEST (python, "plugin-info", plugin_info);
+ EXTENSION_TEST (python, "nonexistent", nonexistent);
return testing_run_tests ();
}
diff --git a/tests/libpeas/extension-seed.c b/tests/libpeas/extension-seed.c
index e35e0ae..cd7923c 100644
--- a/tests/libpeas/extension-seed.c
+++ b/tests/libpeas/extension-seed.c
@@ -64,6 +64,19 @@ test_extension_seed_plugin_info (PeasEngine *engine)
g_object_unref (extension);
}
+static void
+test_extension_seed_nonexistent (PeasEngine *engine)
+{
+ PeasPluginInfo *info;
+
+ testing_util_push_log_hook ("*Failed to open *extension-seed-nonexistent.js*");
+ testing_util_push_log_hook ("Error loading plugin 'extension-seed-nonexistent'");
+
+ info = peas_engine_get_plugin_info (engine, "extension-seed-nonexistent");
+
+ g_assert (!peas_engine_load_plugin (engine, info));
+}
+
int
main (int argc,
char *argv[])
@@ -75,6 +88,7 @@ main (int argc,
EXTENSION_TESTS (seed);
EXTENSION_TEST (seed, "plugin-info", plugin_info);
+ EXTENSION_TEST (seed, "nonexistent", nonexistent);
return testing_run_tests ();
}
diff --git a/tests/libpeas/plugins/Makefile.am b/tests/libpeas/plugins/Makefile.am
index 2c7bac0..f254725 100644
--- a/tests/libpeas/plugins/Makefile.am
+++ b/tests/libpeas/plugins/Makefile.am
@@ -15,14 +15,18 @@ SUBDIRS += extension-seed
endif
noinst_PLUGIN = \
- disabled-loader.plugin \
- info-missing-module.plugin \
- info-missing-name.plugin \
- invalid.plugin \
- invalid-loader.plugin \
- nonexistent-dep.plugin \
- nonexistent-loader.plugin \
- not-loadable.plugin \
+ disabled-loader.plugin \
+ extension-c-nonexistent.plugin \
+ extension-gjs-nonexistent.plugin \
+ extension-python-nonexistent.plugin \
+ extension-seed-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
EXTRA_DIST = $(noinst_PLUGIN)
diff --git a/tests/libpeas/plugins/extension-c-nonexistent.plugin b/tests/libpeas/plugins/extension-c-nonexistent.plugin
new file mode 100644
index 0000000..0372598
--- /dev/null
+++ b/tests/libpeas/plugins/extension-c-nonexistent.plugin
@@ -0,0 +1,8 @@
+[Plugin]
+Module=extension-c-nonexistent
+IAge=2
+Name=Extension C Nonexistent
+Description=This plugin is nonexistent.
+Authors=Garrett Regier
+Copyright=Copyright © 2011 Garrett Regier
+Website=http://live.gnome.org/Libpeas
diff --git a/tests/libpeas/plugins/extension-gjs-nonexistent.plugin b/tests/libpeas/plugins/extension-gjs-nonexistent.plugin
new file mode 100644
index 0000000..ed9c614
--- /dev/null
+++ b/tests/libpeas/plugins/extension-gjs-nonexistent.plugin
@@ -0,0 +1,9 @@
+[Plugin]
+Module=extension-gjs-nonexistent
+Loader=gjs
+IAge=2
+Name=Extension GJS Nonexistent
+Description=This plugin is nonexistent.
+Authors=Garrett Regier
+Copyright=Copyright © 2011 Garrett Regier
+Website=http://live.gnome.org/Libpeas
diff --git a/tests/libpeas/plugins/extension-python-nonexistent.plugin b/tests/libpeas/plugins/extension-python-nonexistent.plugin
new file mode 100644
index 0000000..a557ca6
--- /dev/null
+++ b/tests/libpeas/plugins/extension-python-nonexistent.plugin
@@ -0,0 +1,9 @@
+[Plugin]
+Module=extension-python-nonexistent
+Loader=python
+IAge=2
+Name=Extension Python Nonexistent
+Description=This plugin is nonexistent.
+Authors=Garrett Regier
+Copyright=Copyright © 2011 Garrett Regier
+Website=http://live.gnome.org/Libpeas
diff --git a/tests/libpeas/plugins/extension-seed-nonexistent.plugin b/tests/libpeas/plugins/extension-seed-nonexistent.plugin
new file mode 100644
index 0000000..d187f82
--- /dev/null
+++ b/tests/libpeas/plugins/extension-seed-nonexistent.plugin
@@ -0,0 +1,9 @@
+[Plugin]
+Module=extension-seed-nonexistent
+Loader=seed
+IAge=2
+Name=Extension Seed Nonexistent
+Description=This plugin is nonexistent.
+Authors=Garrett Regier
+Copyright=Copyright © 2011 Garrett Regier
+Website=http://live.gnome.org/Libpeas