[Zope-Checkins] CVS: Zope2 - testrunner.py:1.9
fred@digicool.com
fred@digicool.com
Tue, 17 Apr 2001 11:07:20 -0400 (EDT)
Update of /cvs-repository/Zope2/utilities
In directory korak:/tmp/cvs-serv17196
Modified Files:
testrunner.py
Log Message:
err_exit(): Allow the return code to be passed in, with a default of 2
(the usual Unix return code for command-line errors).
main(): Remove the try/except that caused a second err_exit() call after
the first call to sys.exit(). The try/except also prevented the
first sys.exit() from actually doing so (only the second, unintended
call caused the script to exit).
When the users *asks* for help (-h), use a return code of 0 since
there was not an error that triggered the help message.
--- Updated File testrunner.py in package Zope2 --
--- testrunner.py 2001/03/30 16:03:11 1.8
+++ testrunner.py 2001/04/17 15:07:19 1.9
@@ -158,25 +158,21 @@
filename=None
test_all=None
- try:
- options, arg=getopt.getopt(args, 'ahd:f:')
- if not options:
- err_exit(usage_msg)
- for name, value in options:
- name=name[1:]
- if name == 'a':
- test_all=1
- elif name == 'd':
- pathname=string.strip(value)
- elif name == 'f':
- filename=string.strip(value)
- elif name == 'h':
- err_exit(usage_msg)
- else:
- err_exit(usage_msg)
-
- except:
+ options, arg=getopt.getopt(args, 'ahd:f:')
+ if not options:
err_exit(usage_msg)
+ for name, value in options:
+ name=name[1:]
+ if name == 'a':
+ test_all=1
+ elif name == 'd':
+ pathname=string.strip(value)
+ elif name == 'f':
+ filename=string.strip(value)
+ elif name == 'h':
+ err_exit(usage_msg, 0)
+ else:
+ err_exit(usage_msg)
testrunner=TestRunner(os.getcwd())
if test_all:
@@ -188,9 +184,9 @@
sys.exit(0)
-def err_exit(message):
+def err_exit(message, rc=2):
sys.stderr.write("\n%s\n" % message)
- sys.exit(1)
+ sys.exit(rc)
if __name__ == '__main__':