From: Mike Frysinger Date: Sun, 9 Oct 2011 18:42:01 +0000 (-0400) Subject: tests: add a --help option to make runtest more friendly X-Git-Tag: v2.2.0_alpha65~13 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0e32e6f3b950b6ca05724491cde8c9d04817d670;p=portage.git tests: add a --help option to make runtest more friendly At the moment, trying to do `./runtests.h -h` just produces an ugly and indecipherable traceback. Make it a bit more friendly. Signed-off-by: Mike Frysinger --- diff --git a/pym/portage/tests/__init__.py b/pym/portage/tests/__init__.py index 7f1ed3f70..fa297b5bb 100644 --- a/pym/portage/tests/__init__.py +++ b/pym/portage/tests/__init__.py @@ -5,6 +5,7 @@ import sys import time import unittest +from optparse import OptionParser, OptionValueError try: from unittest.runner import _TextTestResult # new in python-2.7 @@ -23,8 +24,12 @@ def main(): basedir = os.path.dirname(os.path.realpath(__file__)) testDirs = [] - if len(sys.argv) > 1: - suite.addTests(getTestFromCommandLine(sys.argv[1:], basedir)) + usage = "usage: %s [options] [tests to run]" % os.path.basename(sys.argv[0]) + parser = OptionParser(usage=usage) + (options, args) = parser.parse_args(args=sys.argv) + + if len(args) > 1: + suite.addTests(getTestFromCommandLine(args[1:], basedir)) return TextTestRunner(verbosity=2).run(suite) # the os.walk help mentions relative paths as being quirky