Commit f2975491 authored by Colin Walters's avatar Colin Walters Committed by Benjamin Otte

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...
parent 9e57d388
......@@ -33,10 +33,13 @@ typedef enum {
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)
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");
basedir = ".";
if (argc < 2)
const char *basedir;
GFile *dir;
if (g_getenv ("srcdir"))
basedir = g_getenv ("srcdir");
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 ();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment