[evolution-data-server/openismus-work] Some changes to the isolated test fixture



commit 91078cbc54bc1ed9d38950b39d0c7fbff487dc4b
Author: Tristan Van Berkom <tristanvb openismus com>
Date:   Mon Feb 25 19:33:04 2013 +0900

    Some changes to the isolated test fixture
    
     a.) Setup EDS_REGISTRY_MODULES to use the local cache-reaper module
     b.) Setup EDS_CAMEL_PROVIDER_DIR to use the local provider
     c.) Added "source_name" and use separate ESource uids between tests,
         each test in the suite uses a separate ESource name
    
    Note that 'c' is a stop-gap solution to the problem of not being able to
    properly shut-down the whole test D-Bus environment between tests, it should
    be removed once we can address that problem.
    
    Conflicts:
    
        tests/test-server-utils/e-test-server-utils.c

 tests/test-server-utils/Makefile.am           |    2 +
 tests/test-server-utils/e-test-server-utils.c |   45 +++++++++++++++++-------
 tests/test-server-utils/e-test-server-utils.h |    2 +
 3 files changed, 36 insertions(+), 13 deletions(-)
---
diff --git a/tests/test-server-utils/Makefile.am b/tests/test-server-utils/Makefile.am
index 2054eed..4dc4607 100644
--- a/tests/test-server-utils/Makefile.am
+++ b/tests/test-server-utils/Makefile.am
@@ -14,6 +14,8 @@ common_cflags = \
        -DEDS_TEST_SCHEMA_DIR=\""$(abs_top_builddir)/data"\" \
        -DEDS_TEST_ADDRESS_BOOK_DIR=\""$(abs_top_builddir)/addressbook/backends/file/.libs"\" \
        -DEDS_TEST_CALENDAR_DIR=\""$(abs_top_builddir)/calendar/backends/file/.libs"\" \
+       -DEDS_TEST_REGISTRY_DIR=\""$(abs_top_builddir)/modules/cache-reaper/.libs"\" \
+       -DEDS_TEST_CAMEL_DIR=\""$(abs_top_builddir)/camel/providers/local/.libs"\" \
        $(E_DATA_SERVER_CFLAGS) \
        $(GIO_UNIX_CFLAGS) \
        $(NULL)
diff --git a/tests/test-server-utils/e-test-server-utils.c b/tests/test-server-utils/e-test-server-utils.c
index e1cab55..6eb6dc2 100644
--- a/tests/test-server-utils/e-test-server-utils.c
+++ b/tests/test-server-utils/e-test-server-utils.c
@@ -41,6 +41,13 @@
 static ETestDBus *global_test_dbus = NULL;
 #endif
 
+/* The ESource identifier numerical component, this should
+ * not be needed (and should probably be removed) once we
+ * can get rid of the GLOBAL_DBUS_DAEMON hack.
+ */
+static gint global_test_source_id = 0;
+
+
 typedef struct {
        ETestServerFixture *fixture;
        ETestServerClosure *closure;
@@ -69,6 +76,9 @@ setup_environment (void)
        g_assert (g_setenv ("GSETTINGS_SCHEMA_DIR", EDS_TEST_SCHEMA_DIR, TRUE));
        g_assert (g_setenv ("EDS_CALENDAR_MODULES", EDS_TEST_CALENDAR_DIR, TRUE));
        g_assert (g_setenv ("EDS_ADDRESS_BOOK_MODULES", EDS_TEST_ADDRESS_BOOK_DIR, TRUE));
+       g_assert (g_setenv ("EDS_REGISTRY_MODULES", EDS_TEST_REGISTRY_DIR, TRUE));
+       g_assert (g_setenv ("EDS_CAMEL_PROVIDER_DIR", EDS_TEST_CAMEL_DIR, TRUE));
+       g_assert (g_setenv ("GIO_USE_VFS", "local", TRUE));
 }
 
 static void
@@ -111,11 +121,12 @@ e_test_server_utils_source_added (ESourceRegistry *registry,
 {
        GError  *error = NULL;
 
+       if (g_strcmp0 (e_source_get_uid (source), pair->fixture->source_name) != 0)
+               return;
+
        switch (pair->closure->type) {
        case E_TEST_SERVER_ADDRESS_BOOK:
        case E_TEST_SERVER_DIRECT_ADDRESS_BOOK:
-               if (g_strcmp0 (e_source_get_uid (source), ADDRESS_BOOK_SOURCE_UID) != 0)
-                       return;
 
                if (pair->closure->type == E_TEST_SERVER_DIRECT_ADDRESS_BOOK) {
                        pair->fixture->service.book_client = (EBookClient *)
@@ -137,8 +148,6 @@ e_test_server_utils_source_added (ESourceRegistry *registry,
                break;
 
        case E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK:
-               if (g_strcmp0 (e_source_get_uid (source), ADDRESS_BOOK_SOURCE_UID) != 0)
-                       return;
 
                pair->fixture->service.book = e_book_new (source, &error);
                if (!pair->fixture->service.book)
@@ -150,8 +159,6 @@ e_test_server_utils_source_added (ESourceRegistry *registry,
                break;
 
        case E_TEST_SERVER_CALENDAR:
-               if (g_strcmp0 (e_source_get_uid (source), CALENDAR_SOURCE_UID) != 0)
-                       return;
 
                pair->fixture->service.calendar_client = e_cal_client_new (source, 
                                                                           
pair->closure->calendar_source_type,
@@ -165,8 +172,6 @@ e_test_server_utils_source_added (ESourceRegistry *registry,
                break;
 
        case E_TEST_SERVER_DEPRECATED_CALENDAR:
-               if (g_strcmp0 (e_source_get_uid (source), CALENDAR_SOURCE_UID) != 0)
-                       return;
 
                pair->fixture->service.calendar = e_cal_new (source, pair->closure->calendar_source_type);
                if (!pair->fixture->service.calendar)
@@ -205,7 +210,9 @@ e_test_server_utils_bootstrap_idle (FixturePair *pair)
        case E_TEST_SERVER_DIRECT_ADDRESS_BOOK:
        case E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK:
 
-               scratch = e_source_new_with_uid (ADDRESS_BOOK_SOURCE_UID, NULL, &error);
+               pair->fixture->source_name = g_strdup_printf ("%s-%d", ADDRESS_BOOK_SOURCE_UID, 
global_test_source_id++);
+
+               scratch = e_source_new_with_uid (pair->fixture->source_name, NULL, &error);
                if (!scratch)
                        g_error ("Failed to create scratch source for an addressbook: %s", error->message);
 
@@ -217,7 +224,9 @@ e_test_server_utils_bootstrap_idle (FixturePair *pair)
        case E_TEST_SERVER_CALENDAR:
        case E_TEST_SERVER_DEPRECATED_CALENDAR:
 
-               scratch = e_source_new_with_uid (CALENDAR_SOURCE_UID, NULL, &error);
+               pair->fixture->source_name = g_strdup_printf ("%s-%d", CALENDAR_SOURCE_UID, 
global_test_source_id++);
+
+               scratch = e_source_new_with_uid (pair->fixture->source_name, NULL, &error);
                if (!scratch)
                        g_error ("Failed to create scratch source for a calendar: %s", error->message);
 
@@ -355,6 +364,7 @@ e_test_server_utils_teardown (ETestServerFixture *fixture,
                break;
        }
 
+       g_free (fixture->source_name);
        g_object_run_dispose (G_OBJECT (fixture->registry));
        g_object_unref (fixture->registry);
        fixture->registry = NULL;
@@ -378,9 +388,18 @@ e_test_server_utils_teardown (ETestServerFixture *fixture,
 #endif
        }
 
-       /* Cleanup work directory */
-       if (!closure->keep_work_directory && !test_installed_services ())
-               delete_work_directory ();
+       /* Cleanup work directory
+        *
+        * XXX This is avoided for now since we are currently using
+        * a separate ESource UID for each test, removing the work directory
+        * would cause the cache-reaper module to spew error messages when
+        * attempting to move missing removed ESources to the trash.
+        *
+        * This should probably be all completely removed once the
+        * GLOBAL_DBUS_DAEMON clauses can be removed.
+        */
+       /* if (!closure->keep_work_directory && !test_installed_services ()) */
+       /*      delete_work_directory (); */
 
        /* Destroy dynamically allocated closure */
        if (closure->destroy_closure_func)
diff --git a/tests/test-server-utils/e-test-server-utils.h b/tests/test-server-utils/e-test-server-utils.h
index 6851e24..39b242f 100644
--- a/tests/test-server-utils/e-test-server-utils.h
+++ b/tests/test-server-utils/e-test-server-utils.h
@@ -121,6 +121,7 @@ typedef union {
  * @dbus: The D-Bus test scaffold
  * @registry: An #ESourceRegistry
  * @service: The #ETestService
+ * @source_name: A private detail, the ESource name used for this test case
  * @timeout_source_id: A private detail, tracks the idle source which times out if the registry cannot 
create an ESource.
  *
  * A fixture for running tests on the Evolution Data Server
@@ -131,6 +132,7 @@ struct _ETestServerFixture {
        ETestDBus       *dbus;
        ESourceRegistry *registry;
        ETestService     service;
+       gchar           *source_name;
        guint            timeout_source_id;
 };
 


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