python: Add a switch '--quiet' to the test runner.
* lang/python/tests/run-tests.py: Add and honor a switch '--quiet'. This way we can use this script to run Python tests one by one without the noise, and the script will setup the necessary environment for us. Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
parent
ececfd5de8
commit
d0e91d28f6
@ -39,6 +39,8 @@ parser.add_argument('tests', metavar='TEST', type=str, nargs='+',
|
|||||||
help='A test to run')
|
help='A test to run')
|
||||||
parser.add_argument('-v', '--verbose', action="store_true", default=False,
|
parser.add_argument('-v', '--verbose', action="store_true", default=False,
|
||||||
help='Be verbose.')
|
help='Be verbose.')
|
||||||
|
parser.add_argument('-q', '--quiet', action="store_true", default=False,
|
||||||
|
help='Be quiet.')
|
||||||
parser.add_argument('--interpreters', metavar='PYTHON', type=str,
|
parser.add_argument('--interpreters', metavar='PYTHON', type=str,
|
||||||
default=[], action=SplitAndAccumulate,
|
default=[], action=SplitAndAccumulate,
|
||||||
help='Use these interpreters to run the tests, ' +
|
help='Use these interpreters to run the tests, ' +
|
||||||
@ -72,11 +74,14 @@ for interpreter in args.interpreters:
|
|||||||
env = dict(os.environ)
|
env = dict(os.environ)
|
||||||
env["PYTHONPATH"] = builddirs[0]
|
env["PYTHONPATH"] = builddirs[0]
|
||||||
|
|
||||||
|
if not args.quiet:
|
||||||
print("Running tests using {0} ({1})...".format(interpreter, version))
|
print("Running tests using {0} ({1})...".format(interpreter, version))
|
||||||
|
|
||||||
for test in args.tests:
|
for test in args.tests:
|
||||||
status = subprocess.call(
|
status = subprocess.call(
|
||||||
[interpreter, os.path.join(args.srcdir, test)],
|
[interpreter, os.path.join(args.srcdir, test)],
|
||||||
env=env, stdout=out, stderr=err)
|
env=env, stdout=out, stderr=err)
|
||||||
|
if not args.quiet:
|
||||||
print("{0}: {1}".format(status_to_str(status), test))
|
print("{0}: {1}".format(status_to_str(status), test))
|
||||||
results.append(status)
|
results.append(status)
|
||||||
|
|
||||||
@ -85,6 +90,8 @@ def count(status):
|
|||||||
def failed():
|
def failed():
|
||||||
return len(list(filter(lambda x: x not in (0, 77, 99), results)))
|
return len(list(filter(lambda x: x not in (0, 77, 99), results)))
|
||||||
|
|
||||||
print("{0} tests run, {1} succeeded, {2} failed, {3} skipped.".format(
|
if not args.quiet:
|
||||||
|
print("{0} tests run, {1} succeeded, {2} failed, {3} skipped.".format(
|
||||||
len(results), count(0), failed(), count(77)))
|
len(results), count(0), failed(), count(77)))
|
||||||
sys.exit(len(results) - count(0))
|
sys.exit(len(results) - count(0))
|
||||||
|
sys.exit(results[0])
|
||||||
|
Loading…
Reference in New Issue
Block a user