summaryrefslogtreecommitdiff
path: root/runtest.py
diff options
context:
space:
mode:
authoranatoly techtonik <techtonik@gmail.com>2012-12-14 16:09:38 +0300
committeranatoly techtonik <techtonik@gmail.com>2012-12-14 16:09:38 +0300
commit5f527cc2f03bce84d4db7fe1efe83b3c9dd49c11 (patch)
tree7bef6c5896306055307832243e2c3069d176747e /runtest.py
parent57fa7bb98ef84497375a061a79ee39f8ba737687 (diff)
downloadscons-5f527cc2f03bce84d4db7fe1efe83b3c9dd49c11.tar.gz
runtest.py: Gradually moving from getopt to optparse
Diffstat (limited to 'runtest.py')
-rw-r--r--runtest.py41
1 files changed, 33 insertions, 8 deletions
diff --git a/runtest.py b/runtest.py
index 3af77669..d6af07ec 100644
--- a/runtest.py
+++ b/runtest.py
@@ -94,7 +94,6 @@ import time
cwd = os.getcwd()
-all = 0
baseline = 0
builddir = os.path.join(cwd, 'build')
external = 0
@@ -171,9 +170,37 @@ Environment Variables:
PRESERVE, PRESERVE_{PASS,FAIL,NO_RESULT}: preserve test subdirs
TESTCMD_VERBOSE: turn on verbosity in TestCommand
"""
-
-opts, args = getopt.getopt(sys.argv[1:], "3ab:def:hklno:P:p:qsv:Xx:t",
- ['all', 'baseline=', 'builddir=',
+
+
+# "Pass-through" option parsing -- an OptionParser that ignores
+# unknown options and lets them pile up in the leftover argument
+# list. Useful to gradually port getopt to optparse.
+
+from optparse import OptionParser, BadOptionError
+
+class PassThroughOptionParser(OptionParser):
+ def _process_long_opt(self, rargs, values):
+ try:
+ OptionParser._process_long_opt(self, rargs, values)
+ except BadOptionError, err:
+ self.largs.append(err.opt_str)
+ def _process_short_opts(self, rargs, values):
+ try:
+ OptionParser._process_short_opts(self, rargs, values)
+ except BadOptionError, err:
+ self.largs.append(err.opt_str)
+
+parser = PassThroughOptionParser(add_help_option=False)
+parser.add_option('-a', '--all', action='store_true',
+ help="Run all tests.")
+(options, args) = parser.parse_args()
+
+#print "options:", options
+#print "args:", args
+
+
+opts, args = getopt.getopt(args, "3b:def:hklno:P:p:qsv:Xx:t",
+ ['baseline=', 'builddir=',
'debug', 'external', 'file=', 'help', 'no-progress',
'list', 'no-exec', 'noqmtest', 'nopipefiles', 'output=',
'package=', 'passed', 'python=', 'qmtest',
@@ -184,8 +211,6 @@ opts, args = getopt.getopt(sys.argv[1:], "3ab:def:hklno:P:p:qsv:Xx:t",
for o, a in opts:
if o in ['-3']:
python3incompatibilities = 1
- elif o in ['-a', '--all']:
- all = 1
elif o in ['-b', '--baseline']:
baseline = a
elif o in ['--builddir']:
@@ -254,7 +279,7 @@ for o, a in opts:
elif o in ['--xml']:
format = o
-if not args and not all and not testlistfile:
+if not args and not options.all and not testlistfile:
sys.stderr.write("""\
runtest.py: No tests were specified.
List one or more tests on the command line, use the
@@ -649,7 +674,7 @@ elif testlistfile:
tests = [x for x in tests if x[0] != '#']
tests = [x[:-1] for x in tests]
tests = [x.strip() for x in tests]
-elif all and not qmtest:
+elif options.all and not qmtest:
# Find all of the SCons functional tests in the local directory
# tree. This is anything under the 'src' subdirectory that ends
# with 'Tests.py', or any Python script (*.py) under the 'test'