Fix the fix from mac for test-userdata-dir.c

This commit is contained in:
John Ralls 2017-09-16 18:00:55 -07:00
parent 9dc8e6f40a
commit 711cea1f4f

View File

@ -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();