gnucash master: Fix the fix from mac for test-userdata-dir.c
John Ralls
jralls at code.gnucash.org
Sat Sep 16 21:11:24 EDT 2017
Updated via https://github.com/Gnucash/gnucash/commit/711cea1f (commit)
from https://github.com/Gnucash/gnucash/commit/9dc8e6f4 (commit)
commit 711cea1f4fce4c0194713740a362f7014ddfb3b6
Author: John Ralls <jralls at ceridwen.us>
Date: Sat Sep 16 18:00:55 2017 -0700
Fix the fix from mac for test-userdata-dir.c
diff --git a/libgnucash/core-utils/test/test-userdata-dir.c b/libgnucash/core-utils/test/test-userdata-dir.c
index 7970489..91259ac 100644
--- a/libgnucash/core-utils/test/test-userdata-dir.c
+++ b/libgnucash/core-utils/test/test-userdata-dir.c
@@ -83,23 +83,31 @@ main(int argc, char **argv)
{
int i;
char *home_dir = NULL;
+ char *tmp_dir = NULL;
char *userdata_dir = NULL;
char *gnc_data_home_dir = NULL;
if (argc > 1)
+ {
/* One can pass a homedir on the command line. This
* will most likely cause the test to fail, but it can be
* used to pass invalid home directories manually. The
* test error messages should then show the system's temporary
* directory to be used instead */
home_dir = g_strdup(argv[1]);
+ tmp_dir = g_strdup(g_get_tmp_dir());
+ }
else
+ {
/* Set up a fake home directory to play with */
#ifdef MAC_INTEGRATION
home_dir = test_get_userdatadir();
+ tmp_dir = g_strdup(home_dir);
#else
home_dir = g_dir_make_tmp("gnucashXXXXXX", NULL);
+ tmp_dir = g_strdup(g_get_tmp_dir());
#endif
+ }
/* Run usr conf dir tests with a valid and writable homedir */
g_setenv("HOME", home_dir, TRUE);
@@ -111,25 +119,25 @@ main(int argc, char **argv)
if (strs2[i].func_num == 0)
{
- wantout = g_build_filename(home_dir, PACKAGE_NAME, "foo",
+ wantout = g_build_filename(tmp_dir, PACKAGE_NAME, "foo",
(gchar *)NULL);
daout = gnc_build_userdata_path("foo");
}
else if (strs2[i].func_num == 1)
{
- wantout = g_build_filename(home_dir, PACKAGE_NAME, strs2[i].output, "foo",
+ wantout = g_build_filename(tmp_dir, PACKAGE_NAME, strs2[i].output, "foo",
(gchar *)NULL);
daout = gnc_build_book_path("foo");
}
else if (strs2[i].func_num == 2)
{
- wantout = g_build_filename(home_dir, PACKAGE_NAME, strs2[i].output, "foo",
+ wantout = g_build_filename(tmp_dir, PACKAGE_NAME, strs2[i].output, "foo",
(gchar *)NULL);
daout = gnc_build_translog_path("foo");
}
else // if (strs2[i].prefix_home == 3)
{
- wantout = g_build_filename(home_dir, PACKAGE_NAME, strs2[i].output, "foo",
+ wantout = g_build_filename(tmp_dir, PACKAGE_NAME, strs2[i].output, "foo",
(gchar *)NULL);
daout = gnc_build_data_path("foo");
}
@@ -142,6 +150,7 @@ main(int argc, char **argv)
g_free(daout);
}
g_free(home_dir);
+ g_free(tmp_dir);
/* Second run, after properly having called gnc_filepath_init */
gnc_filepath_init(TRUE);
userdata_dir = test_get_userdatadir();
Summary of changes:
libgnucash/core-utils/test/test-userdata-dir.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
More information about the gnucash-changes
mailing list