[glib] Fix up the appinfo test



commit 0fc0754e655a0628c4b25da4fe2ddf261208deb3
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Nov 23 22:21:29 2013 -0500

    Fix up the appinfo test
    
    One testcase was launching appinfo-test from a GAppInfo that
    does not have a filename. In this case, the G_LAUNCHED_DESKTOP_FILE
    envvar is not exported. Make appinfo-test deal with that, without
    spewing warnings.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=711178

 gio/tests/appinfo-test.c |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/gio/tests/appinfo-test.c b/gio/tests/appinfo-test.c
index d8aee25..86d0e49 100644
--- a/gio/tests/appinfo-test.c
+++ b/gio/tests/appinfo-test.c
@@ -5,15 +5,24 @@ int
 main (int argc, char *argv[])
 {
   const gchar *envvar;
-  gint pid_from_env;
 
-  envvar = g_getenv ("GIO_LAUNCHED_DESKTOP_FILE_PID");
-  g_assert (envvar != NULL);
-  pid_from_env = atoi (envvar);
-  g_assert_cmpint (pid_from_env, ==, getpid ());
+  g_test_init (&argc, &argv, NULL);
 
   envvar = g_getenv ("GIO_LAUNCHED_DESKTOP_FILE");
-  g_assert_cmpstr (envvar, ==, g_test_get_filename (G_TEST_DIST, "appinfo-test.desktop", NULL));
+  if (envvar != NULL)
+    {
+      gchar *expected;
+      gint pid_from_env;
+
+      expected = g_test_build_filename (G_TEST_DIST, "appinfo-test.desktop", NULL);
+      g_assert_cmpstr (envvar, ==, expected);
+      g_free (expected);
+
+      envvar = g_getenv ("GIO_LAUNCHED_DESKTOP_FILE_PID");
+      g_assert (envvar != NULL);
+      pid_from_env = atoi (envvar);
+      g_assert_cmpint (pid_from_env, ==, getpid ());
+    }
 
   return 0;
 }


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