Re: [Evolution-hackers] Regarding API breakage and lost test cases



On 10/02/2012 01:30 PM, Tristan Van Berkom wrote:
On 10/01/2012 09:08 PM, Dan Vrátil wrote:
On Monday 01 of October 2012 20:41:07 Tristan Van Berkom wrote:
Hi,
     It's recently come to my attention that a vast API break[0] has
been introduced in the last (3.6) cycle of EDS.

Unfortunately this also breaks the vast majority of the test cases
in EDS proper as well as the benchmarking tests[1] we've been using
to track EDS performance over releases.

After looking through about 1 year's worth of archives, I was
only able to find a single thread[2] remotely related to this
subject so, I'd like to at least raise the question, What is the
rationale behind this API breakage in the 3.6 release ?

Hi,

check this thread [0], probably what you are looking for.



And more practically speaking, is there any clear migration path
towards the new APIs using the ESourceRegistry ?

[1]


Thanks Dan for your prompt reply yesterday.

Those we're indeed what I was looking for.

I'm still trying to find my footing here, the migration guide
and new documentation on ESourceRegistry don't seem to outline
how a new addressbook is actually created.

FWIW, I have something in place that works, but it's a little dirty.

Here's what can be done currently (but needs work to re-integrate
into the tests suite):

  o Create a sandbox directory where EDS will be operating,
    lets call it TESTDIR

  o Create the file:
     $(TESTDIR)/evolution/sources/test-address-book.source

  o The contents of test-address-book.source should be as follows:

    [Data Source]
    DisplayName=Test
    Enabled=true
    Parent=local-stub

    [Address Book]
    BackendName=local
    Color=#becedd

    (NOTE: it should be the same as the EDS created file in
    data/sources/system-address-book.source, I just changed
    the DisplayName to be 'Test')

  o Here is one step I really need to get rid of:

    copy over the installed dbus .service files into /usr/share/dbus-1/

    Ideally we should be running a dbus server that picks up the
    .service files that are not yet installed into your relocated
    build prefix (i.e. make check should run *before* make install)

    So this is just worse than bad, we use the system dbus
    to run the service over and copy the files into /usr :-/

  o Now, setup the environment in which you will run the registry
    and addressbook services:

    export XDG_DATA_HOME=$(TESTDIR)
    export XDG_CACHE_HOME=$(TESTDIR)
    export XDG_CONFIG_HOME=$(TESTDIR)

  o Now everything should be setup to test the addressbook, run:

    /opt/devel/libexec/evolution-source-registry &
    /opt/devel/libexec/evolution-addressbook-factory -r &

  o Now assuming that you have fixed ebook-test-utils.c and
    client-test-utils.c, and uncommented the ebook tests
    in tests/libebook/Makefile.am, you can run tests and
    it will work.

Another problem is that most of the tests in tests/libebook/client
assume that they have created a book with 'new_temp_client()', so
they will be successfully removing that book all the time, which
means you need to comment out the calls to e_client_remove_sync()
all over the place otherwise it will remove the handy file
we've created test-address-book.source

Attaching here quick and dirty patches to the ebook-test-utils.c
and client-test-utils.c for reference.

For now I think I'll leave the tests be, perhaps it will be
better if we know what are the correct semantics for creating
a book first.

Cheers,
          -Tristan


i.e. if I wanted to test a specific addressbook backend,
I would need a way to create one and populate it inside some sandbox
directory.

I'm getting as far as:

    // Create scratch source
    e_source_new_with_uid();

    // Add it to the registry
    e_source_registry_new();
    e_source_registry_add_sources();

    // Fetch the new source from the registry (no longer 'scratch')
    e_source_registry_ref_source();

    // Create the book now that we have a valid source (... or so we
    // suspected)
    e_book_new ();

Problems I'm encountering are:

    a.) It seems that e_source_registry_ref_source() only finds the
        newly created source the next time I startup the test app
        (so this may indicate a bug, that the local registry is not
        updated after adding a new source).

    b.) e_book_new() complains that the new source has no backend:

       "e-book.c:2944: cannot get book from factory:
        No backend name in source 'Unnamed'"

I'm sure I've missed something ridiculous here, while observing
the sources e-data-book-factory.c, it seems that if the source
were given an addressbook extension with the intended backend
name... that it would happily go ahead and create a book.

But, while we do have:
    e_source_get_extension() & e_source_has_extension()

I'm not seeing:
    e_source_add_extension()

Nor am I seeing any factory methods from the addressbook for creating an
appropriate ESource derived object with an addressbook extension.

Well, any insight into what detail I'm missing here would be great.

Thanks,
     -Tristan


I'd like to lend a hand in reviving the buried test cases, currently
the trial-and-error approach is rather costly so any advice on the
topic would be greatly appreciated.

That would be great. Matthew will be back next week and will be able
to give
you more information then I :)

Cheers,
Dan

[0]
https://mail.gnome.org/archives/evolution-hackers/2012-May/msg00055.html
[1] https://live.gnome.org/Evolution/ESourceMigrationGuide


Best,
       -Tristan

[0]
http://git.gnome.org/browse/evolution-data-server/commit/?id=db4474f5463ac3f

1af12e182b20987e65a9b60c5

[1]
http://taschenorakel.de/mathias/2012/06/20/performance-and-memory-usage-of-e

volution-data-server/

[2]
https://mail.gnome.org/archives/evolution-hackers/2011-September/msg00057.ht

ml _______________________________________________
evolution-hackers mailing list
evolution-hackers gnome org
To change your list options or unsubscribe, visit ...
https://mail.gnome.org/mailman/listinfo/evolution-hackers

_______________________________________________
evolution-hackers mailing list
evolution-hackers gnome org
To change your list options or unsubscribe, visit ...
https://mail.gnome.org/mailman/listinfo/evolution-hackers

diff --git a/tests/libebook/client/client-test-utils.c b/tests/libebook/client/client-test-utils.c
index ee6cafe..0b09c4f 100644
--- a/tests/libebook/client/client-test-utils.c
+++ b/tests/libebook/client/client-test-utils.c
@@ -291,31 +291,20 @@ foreach_configured_source_async_next (gpointer *foreach_async_data,
 EBookClient *
 new_temp_client (gchar **uri)
 {
-#if 0  /* ACCOUNT_MGMT */
-	EBookClient *book_client;
-	ESource *source;
-	gchar *abs_uri, *filename;
-	gint handle;
-	GError *error = NULL;
-
-	filename = g_build_filename (g_get_tmp_dir (), "e-book-client-test-XXXXXX/", NULL);
-	handle = g_mkstemp (filename);
-
-	if (handle != -1)
-		close (handle);
 
-	g_return_val_if_fail (g_mkdir_with_parents (filename, 0700) == 0, NULL);
+	ESourceRegistry *registry;
+	EBookClient     *book_client;
+	ESource         *source;
+	const gchar     *uid = "test-address-book";
+	GError          *error = NULL;
 
-	abs_uri = g_strconcat ("local://", filename, NULL);
-	g_free (filename);
+	registry = e_source_registry_new_sync (NULL, &error);
+	if (!registry)
+		g_error ("Unable to create the registry: %s", error->message);
 
-	source = e_source_new_with_absolute_uri ("Test book", abs_uri);
-	if (uri)
-		*uri = abs_uri;
-	else
-		g_free (abs_uri);
-
-	g_return_val_if_fail (source != NULL, NULL);
+	source = e_source_registry_ref_source (registry, uid);
+	if (!source)
+		g_error ("Added source '%s' is not in the registry", uid);
 
 	book_client = e_book_client_new (source, &error);
 	g_object_unref (source);
@@ -324,9 +313,6 @@ new_temp_client (gchar **uri)
 		report_error ("new temp client", &error);
 
 	return book_client;
-#endif /* ACCOUNT_MGMT */
-
-	return NULL;
 }
 
 gchar *
diff --git a/tests/libebook/ebook-test-utils.c b/tests/libebook/ebook-test-utils.c
index c96692a..4a25d69 100644
--- a/tests/libebook/ebook-test-utils.c
+++ b/tests/libebook/ebook-test-utils.c
@@ -641,29 +641,26 @@ ebook_test_utils_book_async_remove_contacts (EBook *book,
 EBook *
 ebook_test_utils_book_new_temp (gchar **uri)
 {
-	EBook *book;
-	gchar *file_template;
-	gchar *uri_result;
+	ESourceRegistry *registry;
+	EBook           *book = NULL;
+	ESource         *source;
+	const gchar     *uid = "test-address-book";
+	GError          *error = NULL;
 
-	file_template = g_build_filename (g_get_tmp_dir (),
-			"ebook-test-XXXXXX/", NULL);
-	g_mkstemp (file_template);
+	registry = e_source_registry_new_sync (NULL, &error);
+	if (!registry)
+		g_error ("Unable to create the registry: %s", error->message);
 
-	uri_result = g_strconcat ("local:", file_template, NULL);
-	if (!uri_result) {
-		g_warning ("failed to convert %s to a 'local:' URI", file_template);
-		exit (1);
-	}
-	g_free (file_template);
+	source = e_source_registry_ref_source (registry, uid);
+	if (!source)
+		g_error ("Added source '%s' is not in the registry", uid);
 
-	/* FIXME We don't build EBooks from URIs anymore. */
-	/* book = ebook_test_utils_book_new_from_uri (uri_result); */
-	book = NULL;
+	book = e_book_new (source, &error);
+	if (!book)
+		g_error ("Unable to create the book: %s", error->message);
 
 	if (uri)
-                *uri = g_strdup (uri_result);
-
-	g_free (uri_result);
+                *uri = g_strdup (uid);
 
 	return book;
 }


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