[libpeas] Tests: do not include main() in the EXTENSION_TESTS macro



commit cc7dbeb1ecaaec973d6e14689e45cff519c6dea3
Author: Steve Frécinaux <code istique net>
Date:   Sun Mar 6 19:16:20 2011 +0100

    Tests: do not include main() in the EXTENSION_TESTS macro

 tests/libpeas/extension-c.c               |   12 +++++++++++-
 tests/libpeas/extension-python.c          |   12 +++++++++++-
 tests/libpeas/extension-seed.c            |    7 +------
 tests/libpeas/testing/testing-extension.h |   26 ++++++++------------------
 4 files changed, 31 insertions(+), 26 deletions(-)
---
diff --git a/tests/libpeas/extension-c.c b/tests/libpeas/extension-c.c
index a231db9..4cc76cb 100644
--- a/tests/libpeas/extension-c.c
+++ b/tests/libpeas/extension-c.c
@@ -25,4 +25,14 @@
 
 #include "testing/testing-extension.h"
 
-EXTENSION_TESTS ("c")
+int
+main (int   argc,
+      char *argv[])
+{
+  g_test_init (&argc, &argv, NULL);
+  g_type_init ();
+
+  EXTENSION_TESTS ("c");
+
+  return testing_run_tests ();
+}
diff --git a/tests/libpeas/extension-python.c b/tests/libpeas/extension-python.c
index c57fb1d..6cc9b85 100644
--- a/tests/libpeas/extension-python.c
+++ b/tests/libpeas/extension-python.c
@@ -25,4 +25,14 @@
 
 #include "testing/testing-extension.h"
 
-EXTENSION_TESTS ("python")
+int
+main (int   argc,
+      char *argv[])
+{
+  g_test_init (&argc, &argv, NULL);
+  g_type_init ();
+
+  EXTENSION_TESTS ("python");
+
+  return testing_run_tests ();
+}
diff --git a/tests/libpeas/extension-seed.c b/tests/libpeas/extension-seed.c
index c40e22f..1288425 100644
--- a/tests/libpeas/extension-seed.c
+++ b/tests/libpeas/extension-seed.c
@@ -35,12 +35,7 @@ main (int   argc,
 
   g_type_init ();
 
-  testing_init ();
-
-  peas_engine_enable_loader (peas_engine_get_default (), "seed");
-  g_object_unref (peas_engine_get_default ());
-
-  testing_extension_set_plugin_ ("extension-" "seed");
+  _EXTENSION_TESTS_INIT ("seed");
 
   _EXTENSION_TEST ("seed", "garbage-collect", garbage_collect);
 
diff --git a/tests/libpeas/testing/testing-extension.h b/tests/libpeas/testing/testing-extension.h
index f0b6663..3269723 100644
--- a/tests/libpeas/testing/testing-extension.h
+++ b/tests/libpeas/testing/testing-extension.h
@@ -59,6 +59,12 @@ void testing_extension_properties_read_only_      (PeasEngine *engine);
 void testing_extension_properties_write_only_     (PeasEngine *engine);
 void testing_extension_properties_readwrite_      (PeasEngine *engine);
 
+#define _EXTENSION_TESTS_INIT(loader) \
+  testing_init (); \
+  peas_engine_enable_loader (peas_engine_get_default (), loader); \
+  g_object_unref (peas_engine_get_default ()); \
+  testing_extension_set_plugin_ ("extension-" loader);
+
 
 #define _EXTENSION_TEST(loader, path, ftest) \
   g_test_add ("/extension/" loader "/" path, TestingExtensionFixture_, \
@@ -68,20 +74,7 @@ void testing_extension_properties_readwrite_      (PeasEngine *engine);
               testing_extension_test_teardown_);
 
 #define EXTENSION_TESTS(loader) \
-int \
-main (int   argc, \
-      char *argv[]) \
-{ \
-  g_test_init (&argc, &argv, NULL); \
-\
-  g_type_init (); \
-\
-  testing_init (); \
-\
-  peas_engine_enable_loader (peas_engine_get_default (), loader); \
-  g_object_unref (peas_engine_get_default ()); \
-\
-  testing_extension_set_plugin_ ("extension-" loader); \
+  _EXTENSION_TESTS_INIT(loader); \
 \
   _EXTENSION_TEST (loader, "garbage-collect", garbage_collect); \
 \
@@ -102,10 +95,7 @@ main (int   argc, \
   _EXTENSION_TEST (loader, "properties-construct-only", properties_construct_only); \
   _EXTENSION_TEST (loader, "properties-read-only", properties_read_only); \
   _EXTENSION_TEST (loader, "properties-write-only", properties_write_only); \
-  _EXTENSION_TEST (loader, "properties-readwrite", properties_readwrite); \
-\
-  return testing_run_tests (); \
-}
+  _EXTENSION_TEST (loader, "properties-readwrite", properties_readwrite);
 
 G_END_DECLS
 



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