[evolution-data-server] Install test vcards if --enable-installed-tests is configured.



commit 210938e98096f801ed59e1c9f0bd57f25f65903d
Author: Tristan Van Berkom <tristanvb openismus com>
Date:   Tue Dec 3 19:10:44 2013 +0900

    Install test vcards if --enable-installed-tests is configured.
    
    Also, load the vcards from ${pkglibexecdir}/installed-tests/vcards
    in the case that TEST_INSTALLED_SERVICES is specified

 tests/libebook/Makefile.am                |   12 +++++++++++-
 tests/libebook/client/Makefile.am         |    1 +
 tests/libebook/client/client-test-utils.c |   10 +++++++++-
 tests/libebook/ebook-test-utils.c         |   10 +++++++++-
 tests/libedata-book/Makefile.am           |    1 +
 tests/libedata-book/data-test-utils.c     |   15 +++++++++++----
 6 files changed, 42 insertions(+), 7 deletions(-)
---
diff --git a/tests/libebook/Makefile.am b/tests/libebook/Makefile.am
index a526048..a371e4e 100644
--- a/tests/libebook/Makefile.am
+++ b/tests/libebook/Makefile.am
@@ -21,6 +21,7 @@ libebook_test_utils_la_CPPFLAGS = \
        -I$(top_srcdir)/tests/test-server-utils \
        -I$(top_builddir)/tests/test-server-utils \
        -DSRCDIR=\""$(abs_srcdir)"\" \
+       -DINSTALLED_TEST_DIR=\""$(pkglibexecdir)/installed-tests"\" \
        $(EVOLUTION_ADDRESSBOOK_CFLAGS) \
        $(EVOLUTION_CALENDAR_CFLAGS) \
        $(CAMEL_CFLAGS) \
@@ -62,7 +63,7 @@ TESTS = \
 
 noinst_PROGRAMS = $(TESTS)
 
-EXTRA_DIST = \
+TEST_VCARDS = \
        $(srcdir)/data/vcards/name-only.vcf \
        $(srcdir)/data/vcards/simple-1.vcf \
        $(srcdir)/data/vcards/simple-2.vcf \
@@ -103,6 +104,15 @@ EXTRA_DIST = \
        $(srcdir)/data/vcards/custom-15.vcf \
        $(NULL)
 
+if EDS_INSTALLED_TESTS_ENABLED
+vcardsdir   = ${pkglibexecdir}/installed-tests/vcards
+vcards_DATA = $(TEST_VCARDS)
+endif
+
+EXTRA_DIST = $(TEST_VCARDS)
+
+
+
 test_ebook_commit_contact_LDADD=$(TEST_LIBS)
 test_ebook_commit_contact_CPPFLAGS=$(TEST_CPPFLAGS)
 test_ebook_get_book_view_LDADD=$(TEST_LIBS)
diff --git a/tests/libebook/client/Makefile.am b/tests/libebook/client/Makefile.am
index 3dc8b4f..fd75c23 100644
--- a/tests/libebook/client/Makefile.am
+++ b/tests/libebook/client/Makefile.am
@@ -18,6 +18,7 @@ libclient_test_utils_la_CPPFLAGS = \
        -I$(top_srcdir)/private \
        -I$(top_builddir)/private \
        -DSRCDIR=\""$(abs_srcdir)"\" \
+       -DINSTALLED_TEST_DIR=\""$(pkglibexecdir)/installed-tests"\" \
        $(EVOLUTION_ADDRESSBOOK_CFLAGS) \
        $(EVOLUTION_CALENDAR_CFLAGS) \
        $(CAMEL_CFLAGS) \
diff --git a/tests/libebook/client/client-test-utils.c b/tests/libebook/client/client-test-utils.c
index d7368c6..a7bbf06 100644
--- a/tests/libebook/client/client-test-utils.c
+++ b/tests/libebook/client/client-test-utils.c
@@ -59,7 +59,15 @@ new_vcard_from_test_case (const gchar *case_name)
        gchar *vcard;
 
        case_filename = g_strdup_printf ("%s.vcf", case_name);
-       filename = g_build_filename (SRCDIR, "..", "data", "vcards", case_filename, NULL);
+
+       /* In the case of installed tests, they run in ${pkglibexecdir}/installed-tests
+        * and the vcards are installed in ${pkglibexecdir}/installed-tests/vcards
+        */
+       if (g_getenv ("TEST_INSTALLED_SERVICES") != NULL)
+               filename = g_build_filename (INSTALLED_TEST_DIR, "vcards", case_filename, NULL);
+       else
+               filename = g_build_filename (SRCDIR, "..", "data", "vcards", case_filename, NULL);
+
        file = g_file_new_for_path (filename);
        if (!g_file_load_contents (file, NULL, &vcard, NULL, NULL, &error)) {
                g_warning (
diff --git a/tests/libebook/ebook-test-utils.c b/tests/libebook/ebook-test-utils.c
index 87d4697..8a3d437 100644
--- a/tests/libebook/ebook-test-utils.c
+++ b/tests/libebook/ebook-test-utils.c
@@ -48,7 +48,15 @@ ebook_test_utils_new_vcard_from_test_case (const gchar *case_name)
        gchar *vcard;
 
        case_filename = g_strdup_printf ("%s.vcf", case_name);
-       filename = g_build_filename (SRCDIR, EBOOK_TEST_UTILS_DATA_DIR, EBOOK_TEST_UTILS_VCARDS_DIR, 
case_filename, NULL);
+
+       /* In the case of installed tests, they run in ${pkglibexecdir}/installed-tests
+        * and the vcards are installed in ${pkglibexecdir}/installed-tests/vcards
+        */
+       if (g_getenv ("TEST_INSTALLED_SERVICES") != NULL)
+               filename = g_build_filename (INSTALLED_TEST_DIR, "vcards", case_filename, NULL);
+       else
+               filename = g_build_filename (SRCDIR, EBOOK_TEST_UTILS_DATA_DIR, EBOOK_TEST_UTILS_VCARDS_DIR, 
case_filename, NULL);
+
        file = g_file_new_for_path (filename);
        if (!g_file_load_contents (file, NULL, &vcard, NULL, NULL, &error)) {
                g_warning (
diff --git a/tests/libedata-book/Makefile.am b/tests/libedata-book/Makefile.am
index 5bc4972..edce8d7 100644
--- a/tests/libedata-book/Makefile.am
+++ b/tests/libedata-book/Makefile.am
@@ -24,6 +24,7 @@ libdata_test_utils_la_CPPFLAGS = \
        -DDATADIR=\"$(datadir)\" \
        -DSRCDIR=\""$(abs_srcdir)"\" \
        -DBUILDDIR=\""$(abs_topbuilddir)"\" \
+       -DINSTALLED_TEST_DIR=\""$(pkglibexecdir)/installed-tests"\" \
        $(EVOLUTION_ADDRESSBOOK_CFLAGS) \
        $(EVOLUTION_CALENDAR_CFLAGS) \
        $(GIO_UNIX_CFLAGS) \
diff --git a/tests/libedata-book/data-test-utils.c b/tests/libedata-book/data-test-utils.c
index 92bd9a9..06a48a4 100644
--- a/tests/libedata-book/data-test-utils.c
+++ b/tests/libedata-book/data-test-utils.c
@@ -35,7 +35,15 @@ new_vcard_from_test_case (const gchar *case_name)
        gchar *vcard;
 
        case_filename = g_strdup_printf ("%s.vcf", case_name);
-       filename = g_build_filename (SRCDIR, "..", "libebook", "data", "vcards", case_filename, NULL);
+
+       /* In the case of installed tests, they run in ${pkglibexecdir}/installed-tests
+        * and the vcards are installed in ${pkglibexecdir}/installed-tests/vcards
+        */
+       if (g_getenv ("TEST_INSTALLED_SERVICES") != NULL)
+               filename = g_build_filename (INSTALLED_TEST_DIR, "vcards", case_filename, NULL);
+       else
+               filename = g_build_filename (SRCDIR, "..", "libebook", "data", "vcards", case_filename, NULL);
+
        file = g_file_new_for_path (filename);
        if (!g_file_load_contents (file, NULL, &vcard, NULL, NULL, &error))
                g_error ("failed to read test contact file '%s': %s",
@@ -188,11 +196,10 @@ e_sqlite_fixture_setup (EbSqlFixture  *fixture,
                                       g_object_unref);
 
        /* Cleanup from last test */
-       directory  = g_build_filename (SRCDIR, "cache", NULL);
+       directory  = g_build_filename (g_get_tmp_dir (), "test-sqlite-cache", NULL);
        delete_work_directory (directory);
        g_free (directory);
-
-       filename = g_build_filename (SRCDIR, "cache", "contacts.db", NULL);
+       filename = g_build_filename (g_get_tmp_dir (), "test-sqlite-cache", "contacts.db", NULL);
 
        if (closure->setup_summary)
                setup = closure->setup_summary ();


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