mirror of https://github.com/GNOME/gimp.git
app: on make check, search menu XML files in both buildir and srcdir
Turn GIMP_TESTING_MENUS_DIR into GIMP_TESTING_MENUS_PATH and look in all its dirs for the menu file.
This commit is contained in:
parent
e325503c81
commit
8516aedade
|
@ -50,9 +50,9 @@
|
|||
#endif /* G_OS_WIN32 */
|
||||
|
||||
void
|
||||
gimp_test_utils_set_env_to_subpath (const gchar *root_env_var,
|
||||
const gchar *subdir,
|
||||
const gchar *target_env_var)
|
||||
gimp_test_utils_set_env_to_subdir (const gchar *root_env_var,
|
||||
const gchar *subdir,
|
||||
const gchar *target_env_var)
|
||||
{
|
||||
const gchar *root_dir = NULL;
|
||||
gchar *target_dir = NULL;
|
||||
|
@ -75,6 +75,55 @@ gimp_test_utils_set_env_to_subpath (const gchar *root_env_var,
|
|||
g_free (target_dir);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_test_utils_set_env_to_subpath (const gchar *root_env_var1,
|
||||
const gchar *root_env_var2,
|
||||
const gchar *subdir,
|
||||
const gchar *target_env_var)
|
||||
{
|
||||
const gchar *root_dir1 = NULL;
|
||||
const gchar *root_dir2 = NULL;
|
||||
gchar *target_dir1 = NULL;
|
||||
gchar *target_dir2 = NULL;
|
||||
gchar *target_path = NULL;
|
||||
|
||||
/* Get root dir */
|
||||
root_dir1 = g_getenv (root_env_var1);
|
||||
if (! root_dir1)
|
||||
g_printerr ("*\n"
|
||||
"* The env var %s is not set, you are probably running\n"
|
||||
"* in a debugger. Set it manually, e.g.:\n"
|
||||
"*\n"
|
||||
"* set env %s=%s/source/gimp\n"
|
||||
"*\n",
|
||||
root_env_var1,
|
||||
root_env_var1, g_get_home_dir ());
|
||||
|
||||
root_dir2 = g_getenv (root_env_var2);
|
||||
if (! root_dir2)
|
||||
g_printerr ("*\n"
|
||||
"* The env var %s is not set, you are probably running\n"
|
||||
"* in a debugger. Set it manually, e.g.:\n"
|
||||
"*\n"
|
||||
"* set env %s=%s/source/gimp\n"
|
||||
"*\n",
|
||||
root_env_var2,
|
||||
root_env_var2, g_get_home_dir ());
|
||||
|
||||
/* Construct path and setup target env var */
|
||||
target_dir1 = g_build_filename (root_dir1, subdir, NULL);
|
||||
target_dir2 = g_build_filename (root_dir2, subdir, NULL);
|
||||
|
||||
target_path = g_strconcat (target_dir1, G_SEARCHPATH_SEPARATOR_S,
|
||||
target_dir2, NULL);
|
||||
|
||||
g_free (target_dir1);
|
||||
g_free (target_dir2);
|
||||
|
||||
g_setenv (target_env_var, target_path, TRUE);
|
||||
g_free (target_path);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gimp_test_utils_set_gimp3_directory:
|
||||
|
@ -89,25 +138,26 @@ void
|
|||
gimp_test_utils_set_gimp3_directory (const gchar *root_env_var,
|
||||
const gchar *subdir)
|
||||
{
|
||||
gimp_test_utils_set_env_to_subpath (root_env_var,
|
||||
subdir,
|
||||
"GIMP3_DIRECTORY" /*target_env_var*/);
|
||||
gimp_test_utils_set_env_to_subdir (root_env_var,
|
||||
subdir,
|
||||
"GIMP3_DIRECTORY" /*target_env_var*/);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_test_utils_setup_menus_dir:
|
||||
* gimp_test_utils_setup_menus_path:
|
||||
*
|
||||
* Sets GIMP_TESTING_MENUS_DIR to "$top_srcdir/menus".
|
||||
* Sets GIMP_TESTING_MENUS_PATH to "$top_srcdir/menus:$top_builddir/menus".
|
||||
**/
|
||||
void
|
||||
gimp_test_utils_setup_menus_dir (void)
|
||||
gimp_test_utils_setup_menus_path (void)
|
||||
{
|
||||
/* GIMP_TESTING_ABS_TOP_SRCDIR is set by the automake test runner,
|
||||
* see Makefile.am
|
||||
*/
|
||||
gimp_test_utils_set_env_to_subpath ("GIMP_TESTING_ABS_TOP_SRCDIR" /*root_env_var*/,
|
||||
"menus" /*subdir*/,
|
||||
"GIMP_TESTING_MENUS_DIR" /*target_env_var*/);
|
||||
gimp_test_utils_set_env_to_subpath ("GIMP_TESTING_ABS_TOP_SRCDIR",
|
||||
"GIMP_TESTING_ABS_TOP_BUILDDIR",
|
||||
"menus",
|
||||
"GIMP_TESTING_MENUS_PATH");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,12 +19,16 @@
|
|||
#define __GIMP_APP_TEST_UTILS_H__
|
||||
|
||||
|
||||
void gimp_test_utils_set_env_to_subpath (const gchar *root_env_var,
|
||||
void gimp_test_utils_set_env_to_subdir (const gchar *root_env_var,
|
||||
const gchar *subdir,
|
||||
const gchar *target_env_var);
|
||||
void gimp_test_utils_set_env_to_subpath (const gchar *root_env_var1,
|
||||
const gchar *root_env_var2,
|
||||
const gchar *subdir,
|
||||
const gchar *target_env_var);
|
||||
void gimp_test_utils_set_gimp3_directory (const gchar *root_env_var,
|
||||
const gchar *subdir);
|
||||
void gimp_test_utils_setup_menus_dir (void);
|
||||
void gimp_test_utils_setup_menus_path (void);
|
||||
void gimp_test_utils_create_image (Gimp *gimp,
|
||||
gint width,
|
||||
gint height);
|
||||
|
|
|
@ -177,7 +177,7 @@ gimp_test_session_load_and_write_session_files (const gchar *loaded_sessionrc,
|
|||
/* Make sure to run this before we use any GIMP functions */
|
||||
gimp_test_utils_set_gimp3_directory ("GIMP_TESTING_ABS_TOP_SRCDIR",
|
||||
"app/tests/gimpdir");
|
||||
gimp_test_utils_setup_menus_dir ();
|
||||
gimp_test_utils_setup_menus_path ();
|
||||
|
||||
/* Note that we expect the resulting sessionrc to be different from
|
||||
* the read file, which is why we check the MD5 of the -expected
|
||||
|
|
|
@ -368,7 +368,7 @@ main(int argc,
|
|||
|
||||
gimp_test_utils_set_gimp3_directory ("GIMP_TESTING_ABS_TOP_SRCDIR",
|
||||
"app/tests/gimpdir");
|
||||
gimp_test_utils_setup_menus_dir ();
|
||||
gimp_test_utils_setup_menus_path ();
|
||||
|
||||
/* Start up GIMP */
|
||||
gimp = gimp_init_for_gui_testing (TRUE /*show_gui*/);
|
||||
|
|
|
@ -135,7 +135,7 @@ int main(int argc, char **argv)
|
|||
|
||||
gimp_test_utils_set_gimp3_directory ("GIMP_TESTING_ABS_TOP_SRCDIR",
|
||||
"app/tests/gimpdir");
|
||||
gimp_test_utils_setup_menus_dir ();
|
||||
gimp_test_utils_setup_menus_path ();
|
||||
|
||||
/* Launch GIMP in single-window mode */
|
||||
g_setenv ("GIMP_TESTING_SESSIONRC_NAME", "sessionrc-2-8-single-window", TRUE /*overwrite*/);
|
||||
|
|
|
@ -476,7 +476,7 @@ int main(int argc, char **argv)
|
|||
|
||||
gimp_test_utils_set_gimp3_directory ("GIMP_TESTING_ABS_TOP_SRCDIR",
|
||||
"app/tests/gimpdir");
|
||||
gimp_test_utils_setup_menus_dir ();
|
||||
gimp_test_utils_setup_menus_path ();
|
||||
|
||||
/* Start up GIMP */
|
||||
gimp = gimp_init_for_gui_testing (TRUE /*show_gui*/);
|
||||
|
|
|
@ -881,7 +881,7 @@ int main(int argc, char **argv)
|
|||
|
||||
gimp_test_utils_set_gimp3_directory ("GIMP_TESTING_ABS_TOP_SRCDIR",
|
||||
"app/tests/gimpdir");
|
||||
gimp_test_utils_setup_menus_dir ();
|
||||
gimp_test_utils_setup_menus_path ();
|
||||
|
||||
/* Start up GIMP */
|
||||
gimp = gimp_init_for_gui_testing (TRUE /*show_gui*/);
|
||||
|
|
|
@ -778,18 +778,36 @@ gimp_ui_manager_entry_load (GimpUIManager *manager,
|
|||
GimpUIManagerUIEntry *entry,
|
||||
GError **error)
|
||||
{
|
||||
gchar *filename = NULL;
|
||||
const gchar *menus_dir_override = g_getenv ("GIMP_TESTING_MENUS_DIR");
|
||||
gchar *filename = NULL;
|
||||
const gchar *menus_path_override = g_getenv ("GIMP_TESTING_MENUS_PATH");
|
||||
|
||||
/* In order for test cases to be able to run without GIMP being
|
||||
* installed yet, allow them to override the menus directory to the
|
||||
* menus dir in the source root
|
||||
*/
|
||||
if (menus_dir_override)
|
||||
filename = g_build_filename (menus_dir_override, entry->basename, NULL);
|
||||
if (menus_path_override)
|
||||
{
|
||||
GList *path = gimp_path_parse (menus_path_override, 2, FALSE, NULL);
|
||||
GList *list;
|
||||
|
||||
for (list = path; list; list = g_list_next (list))
|
||||
{
|
||||
filename = g_build_filename (list->data, entry->basename, NULL);
|
||||
|
||||
if (! list->next ||
|
||||
g_file_test (filename, G_FILE_TEST_EXISTS))
|
||||
break;
|
||||
|
||||
g_free (filename);
|
||||
}
|
||||
|
||||
g_list_free_full (path, g_free);
|
||||
}
|
||||
else
|
||||
filename = g_build_filename (gimp_data_directory (), "menus",
|
||||
entry->basename, NULL);
|
||||
{
|
||||
filename = g_build_filename (gimp_data_directory (), "menus",
|
||||
entry->basename, NULL);
|
||||
}
|
||||
|
||||
if (manager->gimp->be_verbose)
|
||||
g_print ("loading menu '%s' for %s\n",
|
||||
|
|
Loading…
Reference in New Issue