Commit e633c64b authored by Guido van Rossum's avatar Guido van Rossum

Catch exceptions and print traceback, then continue, rather than

stopping on the first exception.

Add -q option that supprresses most output (diffs and tracebacks).
parent 35ef4ed2
...@@ -92,6 +92,7 @@ import os ...@@ -92,6 +92,7 @@ import os
import string import string
from cStringIO import StringIO from cStringIO import StringIO
import glob import glob
import traceback
import driver import driver
...@@ -116,6 +117,10 @@ def nicerange(lo, hi): ...@@ -116,6 +117,10 @@ def nicerange(lo, hi):
def main(): def main():
opts = [] opts = []
args = sys.argv[1:] args = sys.argv[1:]
quiet = 0
if args and args[0] == "-q":
quiet = 1
del args[0]
while args and args[0][:1] == '-': while args and args[0][:1] == '-':
opts.append(args[0]) opts.append(args[0])
del args[0] del args[0]
...@@ -128,11 +133,18 @@ def main(): ...@@ -128,11 +133,18 @@ def main():
sys.stdout.flush() sys.stdout.flush()
save = sys.stdout, sys.argv save = sys.stdout, sys.argv
try: try:
sys.stdout = stdout = StringIO() try:
sys.argv = [""] + opts + [arg] sys.stdout = stdout = StringIO()
driver.main() sys.argv = [""] + opts + [arg]
finally: driver.main()
sys.stdout, sys.argv = save finally:
sys.stdout, sys.argv = save
except:
print sys.exc_type
errors = 1
if not quiet:
traceback.print_exc()
continue
head, tail = os.path.split(arg) head, tail = os.path.split(arg)
outfile = os.path.join( outfile = os.path.join(
head, head,
...@@ -155,7 +167,7 @@ def main(): ...@@ -155,7 +167,7 @@ def main():
else: else:
print "not OK" print "not OK"
errors = 1 errors = 1
if expected is not None: if not quiet and expected is not None:
showdiff(expected, actual) showdiff(expected, actual)
if errors: if errors:
sys.exit(1) sys.exit(1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment