gnucash stable: Fix invalid home test
Geert Janssens
gjanssens at code.gnucash.org
Thu Oct 31 07:44:11 EDT 2024
Updated via https://github.com/Gnucash/gnucash/commit/831ce065 (commit)
from https://github.com/Gnucash/gnucash/commit/cf73829e (commit)
commit 831ce065bb61f16b06aac812b1ac0fa9a5d1bef2
Author: Geert Janssens <geert at kobaltwit.be>
Date: Thu Oct 31 12:42:19 2024 +0100
Fix invalid home test
If a user has set environment variable GNC_DATA_HOME
to a valid directory (containing real gnucash metadata)
the test would fail. It expects to follow the code path
to set up a gnucash data home directory in the temporary
directory, but the directory pointed to in GNC_DATA_HOME
is used instead.
Fix this by also setting environment variable GNC_DATA_HOME
to something invalid during the test.
diff --git a/libgnucash/core-utils/test/test-userdata-dir-invalid-home.c b/libgnucash/core-utils/test/test-userdata-dir-invalid-home.c
index 3ec1e98946..449a4b1c24 100644
--- a/libgnucash/core-utils/test/test-userdata-dir-invalid-home.c
+++ b/libgnucash/core-utils/test/test-userdata-dir-invalid-home.c
@@ -72,6 +72,7 @@ main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv)
const char *tmp_dir = g_get_tmp_dir();
const char *builddir = g_getenv ("GNC_BUILDDIR");
char *homedir = g_build_filename (builddir, "notexist", NULL);
+ char *testdatahome = g_build_filename (homedir, "gnucash", NULL);
/* Assume we're not in a build environment to test
* the function's actual behaviour in a real world use case, using
@@ -83,7 +84,9 @@ main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv)
* The code should fall back to using the temporary
* directory in that case. */
g_setenv("HOME", homedir, TRUE);
+ g_setenv("GNC_DATA_HOME", testdatahome, TRUE);
g_free (homedir);
+ g_free (testdatahome);
for (i = 0; strs2[i].funcname != NULL; i++)
{
Summary of changes:
libgnucash/core-utils/test/test-userdata-dir-invalid-home.c | 3 +++
1 file changed, 3 insertions(+)
More information about the gnucash-changes
mailing list