[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] Implement the `--help' option for the test suites

From: Madan U Sreenivasan <madan_at_collab.net>
Date: 2006-06-13 01:43:44 CEST

Hi,

    The C and Python test suites now support more than just the test-number
and the list arguments. With a host of options, it becomes necessary to
have a `--help' option too.

    Sometime back, I had submitted a patch for the python test suite.
cmpilato suggested I do the same for the C test suite too.

    Pl. find attached a patch that implements the long-awaited '--help'
option for both the C and python test suites.

[[[
Add the `--help' option for the C and python test suites.

Review By: djames
            rooneg

Suggested By: cmpilato (--help for the C test framework)

* subversion/tests/svn_test_main.c
   (cl_options): Added item, and enum member for `help_opt'.
   (usage): New function to print usage information.
   (main): Added case for handling the `--help' option.

* subversion/tests/cmdline/svntest/main.py
   (usage): New function to print usage information.
   (run_tests): Implemented the `--help' option.
]]]

    Pl. let me know if you need more information.

Regards,
Madan.

Index: subversion/tests/svn_test_main.c
===================================================================
--- subversion/tests/svn_test_main.c (revision 20043)
+++ subversion/tests/svn_test_main.c (working copy)
@@ -53,7 +53,8 @@
   cleanup_opt = SVN_OPT_FIRST_LONGOPT_ID,
   fstype_opt,
   list_opt,
- verbose_opt
+ verbose_opt,
+ help_opt
 };
 
 static const apr_getopt_option_t cl_options[] =
@@ -66,6 +67,8 @@
                     N_("lists all the tests with their short description")},
   {"verbose", verbose_opt, 0,
                     N_("print extra information")},
+ {"help", help_opt, 0,
+ N_("print help information")},
   {0, 0, 0, 0}
 };
 
@@ -146,7 +149,38 @@
 }
 
 
+/* Print usage information. */
+static void
+usage(char *cmd)
+{
+ char *usage_str = "usage: %s [options] [arguments]\n"
+ "If a valid test case number is provided, execute that test.\n"
+ "Otherwise execute all the tests in %s.\n"
+ "\n"
+ "Available options are:\n"
+ " --help : Print this usage message.\n"
+ " --url arg : Use ARG as the base url for test execution.\n"
+ " --list : List the tests available in %s.\n"
+ " --fs-type arg : Create repositories using fs backend ARG.\n"
+ " ARG could be either 'bdb' (default) or 'fsfs'.\n"
+ " -v [--verbose] : Print verbose output.\n"
+ " --cleanup : Cleanup the data leftover from the earlier\n"
+ " test executions.\n"
+ "\n"
+ "Available arguments are:\n"
+ " arg : A valid test case number.\n"
+ " list : Deprecated form of the --list option.\n"
+ " BASE_URL=arg : An alternate form of the --url option.\n\n";
 
+ /* Ignore the "lt-" if it preceeds the script name */
+ if (! strncmp(cmd, "lt-", 3))
+ cmd += 3;
+
+ printf(usage_str, cmd, cmd, cmd);
+
+}
+
+
 /* Execute a test number TEST_NUM. Pretty-print test name and dots
    according to our test-suite spec, and return the result code. */
 static int
@@ -304,6 +338,10 @@
         case verbose_opt:
           verbose_mode = 1;
           break;
+ case help_opt:
+ /* Print usage */
+ usage(svn_path_basename(argv[0], pool));
+ exit(0);
       }
     }
 
Index: subversion/tests/cmdline/svntest/main.py
===================================================================
--- subversion/tests/cmdline/svntest/main.py (revision 20043)
+++ subversion/tests/cmdline/svntest/main.py (working copy)
@@ -769,6 +769,31 @@
   return exit_code
 
 
+def usage(testscript):
+ """Print the usage information for the given testscript.
+ The arguments/options list is the same for all tests."""
+
+ usage_str = """usage: %s [options] [arguments]
+If a valid test case number is provided, execute that test.
+Otherwise execute all the tests in %s.
+
+Available options are:
+ --help : Print this usage message.
+ --url arg : Use ARG as the base url for test execution.
+ --list : List the tests available in %s.
+ --fs-type arg : Create repositories using fs backend ARG.
+ ARG could be either 'bdb' (default) or 'fsfs'.
+ -v [--verbose] : Print verbose output.
+ --cleanup : Cleanup the data leftover from the earlier
+ test executions.
+
+Available arguments are:
+ arg : A valid test case number.
+ list : The deprecated form of --list.
+ BASE_URL=arg : An alternate form of --url.\n""" \
+ % (testscript, testscript, testscript)
+ print usage_str
+
 # Main func. This is the "entry point" that all the test scripts call
 # to run their list of tests.
 #
@@ -801,7 +826,9 @@
   os.environ['SVN_EDITOR'] = ''
 
   opts, args = my_getopt(sys.argv[1:], 'v',
- ['url=', 'fs-type=', 'verbose', 'cleanup', 'list'])
+ ['url=', 'fs-type=', 'verbose', 'cleanup', 'list',
+ 'help'])
+ cmd = os.path.basename(sys.argv[0])
 
   for arg in args:
     if arg == "list":
@@ -813,6 +840,10 @@
       testnums.append(int(arg))
 
   for opt, val in opts:
+ if opt == "--help":
+ usage(cmd)
+ sys.exit(0)
+
     if opt == "--url":
       test_area_url = val
 

Add the `--help' option for the C and python test suites.

Review By: djames
           rooneg

Suggested By: cmpilato (--help for the C test framework)

* subversion/tests/svn_test_main.c
  (cl_options): Added item, and enum member for `help_opt'.
  (usage): New function to print usage information.
  (main): Added case for handling the `--help' option.

* subversion/tests/cmdline/svntest/main.py
  (usage): New function to print usage information.
  (run_tests): Implemented the `--help' option.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Jun 12 20:14:22 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.