[libpeas] Fix disable-loader test and expand it
- From: Steve Frécinaux <sfre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libpeas] Fix disable-loader test and expand it
- Date: Wed, 9 Feb 2011 00:14:46 +0000 (UTC)
commit bbf9dfd78136b5402e823473120e87dbe00a642c
Author: Garrett Regier <alias301 gmail com>
Date: Sun Feb 6 02:57:05 2011 -0800
Fix disable-loader test and expand it
tests/libpeas/engine.c | 30 ++++++++++++++++++-------
tests/libpeas/plugins/Makefile.am | 1 +
tests/libpeas/plugins/loader-disabled.plugin | 8 +++++++
tests/libpeas/testing/testing.c | 6 ++++-
4 files changed, 35 insertions(+), 10 deletions(-)
---
diff --git a/tests/libpeas/engine.c b/tests/libpeas/engine.c
index 48b81d5..3cfc0e7 100644
--- a/tests/libpeas/engine.c
+++ b/tests/libpeas/engine.c
@@ -23,6 +23,7 @@
#include <config.h>
#endif
+#include <stdlib.h>
#include <glib.h>
#include <libpeas/peas.h>
@@ -258,24 +259,37 @@ test_engine_invalid_loader (PeasEngine *engine)
g_assert (!peas_plugin_info_is_available (info));
}
-#ifdef CANNOT_TEST
static void
test_engine_disable_loader (PeasEngine *engine)
{
PeasPluginInfo *info;
- /* Cannot be run because the engine
- * has already loaded the C plugin loader
+ /* We have to use an unused loader because loaders
+ * cannot be disabled after the loader has been loaded.
+ *
+ * The loader is disabled in testing_engine_new()
*/
- info = peas_engine_get_plugin_info (engine, "loadable");
-
- peas_engine_disable_loader (engine, "C");
+ info = peas_engine_get_plugin_info (engine, "loader-disabled");
g_assert (!peas_engine_load_plugin (engine, info));
g_assert (!peas_plugin_info_is_loaded (info));
+ g_assert (!peas_plugin_info_is_available (info));
+
+
+ info = peas_engine_get_plugin_info (engine, "loadable");
+
+ g_assert (peas_engine_load_plugin (engine, info));
+
+ /* Cannot disable the C loader as it has already been enabled */
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
+ {
+ peas_engine_disable_loader (engine, "C");
+ exit (0);
+ }
+ g_test_trap_assert_failed ();
+ g_test_trap_assert_stderr ("*Loader 'C' cannot be disabled*");
}
-#endif
int
main (int argc,
@@ -305,9 +319,7 @@ main (int argc,
TEST ("loaded-plugins", loaded_plugins);
TEST ("invalid-loader", invalid_loader);
-#ifdef CANNOT_TEST
TEST ("disable-loader", disable_loader);
-#endif
#undef TEST
diff --git a/tests/libpeas/plugins/Makefile.am b/tests/libpeas/plugins/Makefile.am
index 7874100..ba20a3c 100644
--- a/tests/libpeas/plugins/Makefile.am
+++ b/tests/libpeas/plugins/Makefile.am
@@ -13,6 +13,7 @@ noinst_DATA = \
info-missing-module.plugin \
info-missing-name.plugin \
invalid-loader.plugin \
+ loader-disabled.plugin \
os-dependant-help.plugin
EXTRA_DIST = $(noinst_DATA)
diff --git a/tests/libpeas/plugins/loader-disabled.plugin b/tests/libpeas/plugins/loader-disabled.plugin
new file mode 100644
index 0000000..51ec551
--- /dev/null
+++ b/tests/libpeas/plugins/loader-disabled.plugin
@@ -0,0 +1,8 @@
+[Plugin]
+Module=loader-disabled
+Loader=disabled
+IAge=2
+Name=Loader Disabled
+Description=This plugin has a disabled loader.
+Authors=Garrett Regier
+Copyright=Copyright © 2011 Garrett Regier
diff --git a/tests/libpeas/testing/testing.c b/tests/libpeas/testing/testing.c
index 93014b2..318a39d 100644
--- a/tests/libpeas/testing/testing.c
+++ b/tests/libpeas/testing/testing.c
@@ -47,7 +47,8 @@ static const gchar *allowed_patterns[] = {
"*Could not find 'Name' in *info-missing-name.plugin*",
"*Error loading *info-missing-iage.plugin*",
"*Error loading *info-missing-module.plugin*",
- "*Error loading *info-missing-name.plugin*"
+ "*Error loading *info-missing-name.plugin*",
+ "*Could not find loader 'disabled'*"
};
static void
@@ -116,6 +117,9 @@ testing_engine_new (void)
/* Must be after requiring typelibs */
engine = peas_engine_get_default ();
+ /* Disabled here incase another tests tries to load it */
+ peas_engine_disable_loader (engine, "disabled");
+
peas_engine_add_search_path (engine, BUILDDIR "/tests/plugins", NULL);
peas_engine_add_search_path (engine, BUILDDIR "/tests/libpeas/plugins", NULL);
peas_engine_rescan_plugins (engine);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]