[gnome-software/wip/ubuntu-xenial] trivial: Fix the self tests



commit e89d3203284e45a76e6469d4d95052c811e86eb9
Author: William Hua <william hua canonical com>
Date:   Tue Apr 26 10:15:10 2016 +0200

    trivial: Fix the self tests

 src/Makefile.am    |    1 +
 src/gs-self-test.c |   21 +++++++++++++++++----
 2 files changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index f626237..eb13f14 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -17,6 +17,7 @@ AM_CPPFLAGS =                                         \
        -DDATADIR=\"$(datadir)\"                        \
        -DVERSION="\"$(VERSION)\""                      \
        -DLOCALEDIR=\""$(localedir)"\"                  \
+       -DTESTDATADIR=\""$(top_srcdir)/data"\"          \
        -DGS_DATA=\"$(pkgdatadir)\"
 
 @INTLTOOL_DESKTOP_RULE@
diff --git a/src/gs-self-test.c b/src/gs-self-test.c
index b85aa33..e66c515 100644
--- a/src/gs-self-test.c
+++ b/src/gs-self-test.c
@@ -24,6 +24,7 @@
 #include <glib.h>
 #include <glib-object.h>
 #include <glib/gstdio.h>
+#include <stdlib.h>
 
 #include "gs-app.h"
 #include "gs-markdown.h"
@@ -32,6 +33,22 @@
 #include "gs-plugin-loader-sync.h"
 #include "gs-utils.h"
 
+/**
+ * gs_test_get_filename:
+ **/
+static gchar *
+gs_test_get_filename (const gchar *filename)
+{
+       gchar *tmp;
+       char full_tmp[PATH_MAX];
+       g_autofree gchar *path = NULL;
+       path = g_build_filename (TESTDATADIR, filename, NULL);
+       tmp = realpath (path, full_tmp);
+       if (tmp == NULL)
+               return NULL;
+       return g_strdup (full_tmp);
+}
+
 static void
 gs_markdown_func (void)
 {
@@ -686,10 +703,6 @@ gs_plugin_loader_dpkg_func (GsPluginLoader *plugin_loader)
        g_autofree gchar *fn = NULL;
        g_autoptr(GFile) file = NULL;
 
-       /* no dpkg, abort */
-       if (!gs_plugin_loader_get_enabled (plugin_loader, "dpkg"))
-               return;
-
        /* load local file */
        fn = gs_test_get_filename ("tests/chiron-1.1-1.deb");
        g_assert (fn != NULL);


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