[neon/backports-focal/xdg-desktop-portal/Neon/unstable] tests: tests: Don't rely on PATH to launch uninstalled

Bastien Nocera null at kde.org
Wed Jan 13 06:32:42 GMT 2021


Git commit 22d666dd7e7fe3f2c3769288e0baa76a507298d8 by Bastien Nocera.
Committed on 22/04/2020 at 14:15.
Pushed by ash into branch 'Neon/unstable'.

tests: Don't rely on PATH to launch uninstalled

Use the build directories instead.

M  +8    -6    tests/test-portals.c

https://invent.kde.org/neon/backports-focal/xdg-desktop-portal/commit/22d666dd7e7fe3f2c3769288e0baa76a507298d8

diff --git a/tests/test-portals.c b/tests/test-portals.c
index c30ab13..728af1a 100644
--- a/tests/test-portals.c
+++ b/tests/test-portals.c
@@ -80,6 +80,7 @@ global_setup (void)
   g_autofree gchar *backends_executable = NULL;
   g_autofree gchar *services = NULL;
   g_autofree gchar *portal_dir = NULL;
+  g_autofree gchar *argv0 = NULL;
   g_autoptr(GSubprocessLauncher) launcher = NULL;
   guint name_timeout;
   const char *argv[4];
@@ -158,12 +159,12 @@ global_setup (void)
   g_subprocess_launcher_setenv (launcher, "XDG_DATA_HOME", outdir, TRUE);
   g_subprocess_launcher_setenv (launcher, "PATH", g_getenv ("PATH"), TRUE);
 
-  /* When running uninstalled we rely on this being added to PATH */
   if (g_getenv ("XDP_UNINSTALLED") != NULL)
-    argv[0] = "xdg-desktop-portal";
+    argv0 = g_test_build_filename (G_TEST_BUILT, "..", "xdg-desktop-portal", NULL);
   else
-    argv[0] = LIBEXECDIR "/xdg-desktop-portal";
+    argv0 = g_strdup (LIBEXECDIR "/xdg-desktop-portal");
 
+  argv[0] = argv0;
   argv[1] = g_test_verbose () ? "--verbose" : NULL;
   argv[2] = NULL;
 
@@ -171,6 +172,7 @@ global_setup (void)
 
   portals = g_subprocess_launcher_spawnv (launcher, argv, &error);
   g_assert_no_error (error);
+  g_clear_pointer (&argv0, g_free);
 
   name_timeout = g_timeout_add (1000, timeout_cb, "Failed to launch xdg-desktop-portal");
 
@@ -197,12 +199,12 @@ global_setup (void)
   g_subprocess_launcher_setenv (launcher, "XDG_DATA_HOME", outdir, TRUE);
   g_subprocess_launcher_setenv (launcher, "PATH", g_getenv ("PATH"), TRUE);
 
-  /* When running uninstalled we rely on this being added to PATH */
   if (g_getenv ("XDP_UNINSTALLED") != NULL)
-    argv[0] = "xdg-permission-store";
+    argv0 = g_test_build_filename (G_TEST_BUILT, "..", "xdg-permission-store", NULL);
   else
-    argv[0] = LIBEXECDIR "/xdg-permission-store";
+    argv0 = g_strdup (LIBEXECDIR "/xdg-permission-store");
 
+  argv[0] = argv0;
   argv[1] = "--replace";
   argv[2] = g_test_verbose () ? "--verbose" : NULL;
   argv[3] = NULL;



More information about the Neon-commits mailing list