[gtk+] Add a --directory option to accessibility-dump



commit a631056808029202ebae32d51c611bd73ddf5144
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue May 14 23:18:05 2013 -0400

    Add a --directory option to accessibility-dump
    
    This will be used to tell it where its test data resides
    when running the a11y tests installed.

 tests/a11y/accessibility-dump.c |   36 ++++++++++++++++++++++++++++++++++--
 1 files changed, 34 insertions(+), 2 deletions(-)
---
diff --git a/tests/a11y/accessibility-dump.c b/tests/a11y/accessibility-dump.c
index 8d4b2b1..62541a1 100644
--- a/tests/a11y/accessibility-dump.c
+++ b/tests/a11y/accessibility-dump.c
@@ -819,17 +819,49 @@ add_tests_for_files_in_directory (GFile *dir)
   g_list_free_full (files, g_object_unref);
 }
 
+static char *arg_base_dir = NULL;
+
+static const GOptionEntry test_args[] = {
+  { "directory",        'd', 0, G_OPTION_ARG_FILENAME, &arg_base_dir,
+    "Directory to run tests from", "DIR" },
+  { NULL }
+};
+
+static gboolean
+parse_command_line (int *argc, char ***argv)
+{
+  GError *error = NULL;
+  GOptionContext *context;
+
+  context = g_option_context_new ("- run GTK accessibility tests");
+  g_option_context_add_main_entries (context, test_args, NULL);
+  g_option_context_set_ignore_unknown_options (context, TRUE);
+
+  if (!g_option_context_parse (context, argc, argv, &error))
+    {
+      g_print ("option parsing failed: %s\n", error->message);
+      return FALSE;
+    }
+
+  gtk_test_init (argc, argv);
+
+  return TRUE;
+}
+
 int
 main (int argc, char **argv)
 {
-  gtk_test_init (&argc, &argv);
+  if (!parse_command_line (&argc, &argv))
+    return 1;
 
   if (argc < 2)
     {
       const char *basedir;
       GFile *dir;
 
-      if (g_getenv ("srcdir"))
+      if (arg_base_dir)
+        basedir = arg_base_dir;
+      else if (g_getenv ("srcdir"))
         basedir = g_getenv ("srcdir");
       else
         basedir = ".";


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]