mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 19:00:08 +00:00
reftests: Add a --directory/-d option
This sets the directory we chdir() to, so we can use relative filenames in ui files. Some properties like to take filenames...
This commit is contained in:
parent
9e57d388e3
commit
f297549139
@ -33,10 +33,13 @@ typedef enum {
|
||||
#define GTK_STYLE_PROVIDER_PRIORITY_FORCE G_MAXUINT
|
||||
|
||||
static char *arg_output_dir = NULL;
|
||||
static char *arg_base_dir = NULL;
|
||||
|
||||
static const GOptionEntry test_args[] = {
|
||||
{ "output", 'o', 0, G_OPTION_ARG_FILENAME, &arg_output_dir,
|
||||
"Directory to save image files to", "DIR" },
|
||||
{ "directory", 'd', 0, G_OPTION_ARG_FILENAME, &arg_base_dir,
|
||||
"Directory to run tests from", "DIR" },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
@ -566,6 +569,8 @@ add_tests_for_files_in_directory (GFile *dir)
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
const char *basedir;
|
||||
|
||||
/* I don't want to fight fuzzy scaling algorithms in GPUs,
|
||||
* so unles you explicitly set it to something else, we
|
||||
* will use Cairo's image surface.
|
||||
@ -575,16 +580,17 @@ main (int argc, char **argv)
|
||||
if (!parse_command_line (&argc, &argv))
|
||||
return 1;
|
||||
|
||||
if (arg_base_dir)
|
||||
basedir = arg_base_dir;
|
||||
else if (g_getenv ("srcdir"))
|
||||
basedir = g_getenv ("srcdir");
|
||||
else
|
||||
basedir = ".";
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
const char *basedir;
|
||||
GFile *dir;
|
||||
|
||||
if (g_getenv ("srcdir"))
|
||||
basedir = g_getenv ("srcdir");
|
||||
else
|
||||
basedir = ".";
|
||||
|
||||
dir = g_file_new_for_path (basedir);
|
||||
|
||||
add_tests_for_files_in_directory (dir);
|
||||
@ -605,6 +611,12 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
/* We need to ensure the process' current working directory
|
||||
* is the same as the reftest data, because we're using the
|
||||
* "file" property of GtkImage as a relative path in builder files.
|
||||
*/
|
||||
chdir (basedir);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user