[tracker-miners/tracker-miners-2.1] libtracker-common: improve test_path_evaluate_name environment handling
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker-miners/tracker-miners-2.1] libtracker-common: improve test_path_evaluate_name environment handling
- Date: Thu, 21 Feb 2019 10:33:51 +0000 (UTC)
commit 2633dd1a46e607ff9ab3f233faf98e07906efbbd
Author: Mart Raudsepp <leio gentoo org>
Date: Sun Feb 17 15:33:26 2019 +0100
libtracker-common: improve test_path_evaluate_name environment handling
Under some environments $PWD might not point where we expect, so simply
use g_get_current_dir() instead.
g_getenv() is documented to return a pointer that may get overwritten
by subsequent calls to g_getenv, g_setenv of g_unsetenv. As even after
removing the second g_getenv, there's still g_setenv calls, take a copy.
See: https://gitlab.gnome.org/GNOME/tracker/merge_requests/59
(cherry-picked from 2b4069e02daf7ce79c58d70ebb9afceff334f88e)
tests/libtracker-miners-common/tracker-file-utils-test.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/tests/libtracker-miners-common/tracker-file-utils-test.c
b/tests/libtracker-miners-common/tracker-file-utils-test.c
index 93b94472c..0b74b512a 100644
--- a/tests/libtracker-miners-common/tracker-file-utils-test.c
+++ b/tests/libtracker-miners-common/tracker-file-utils-test.c
@@ -134,14 +134,14 @@ test_path_list_filter_duplicates_with_exceptions ()
static void
test_path_evaluate_name (void)
{
- gchar *result, *expected;
+ gchar *result, *expected, *pwd, *home;
- const gchar *home = g_getenv ("HOME");
- const gchar *pwd = g_getenv ("PWD");
const gchar *test = "/one/two";
gchar *parent_dir;
+ home = g_strdup (g_getenv ("HOME"));
+ pwd = g_get_current_dir ();
g_setenv ("TEST_TRACKER_DIR", test, TRUE);
@@ -219,6 +219,8 @@ test_path_evaluate_name (void)
result = tracker_path_evaluate_name (tracker_test_helpers_get_nonutf8 ());
g_assert_cmpstr (result, ==, tracker_test_helpers_get_nonutf8 ());
+ g_free (home);
+ g_free (pwd);
g_unsetenv ("TEST_TRACKER_DIR");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]