Improve output of test.py

Add some extra whitespace and report number of failures.

Change-Id: I359b6c5d78dc11c50386be9fc4385a4e8cccb921
This commit is contained in:
Andreas Jaeger 2013-10-09 09:48:40 +02:00
parent 3da9ba776b
commit 7dc0c22682
1 changed files with 31 additions and 20 deletions

51
test.py
View File

@ -308,10 +308,11 @@ def check_deleted_files(rootdir, file_exceptions, verbose):
def validate_one_file(schema, rootdir, path, verbose, def validate_one_file(schema, rootdir, path, verbose,
any_failures, check_syntax, check_niceness): check_syntax, check_niceness):
"""Validate a single file""" """Validate a single file"""
# We pass schema in as a way of caching it, generating it is expensive # We pass schema in as a way of caching it, generating it is expensive
any_failures = False
if verbose: if verbose:
print(" Validating %s" % os.path.relpath(path, rootdir)) print(" Validating %s" % os.path.relpath(path, rootdir))
try: try:
@ -347,6 +348,7 @@ def validate_individual_files(rootdir, exceptions, verbose,
schema = get_schema() schema = get_schema()
any_failures = False any_failures = False
no_validated = 0 no_validated = 0
no_failed = 0
# Do not select delete files, just Added, Copied, Modified, Renamed, # Do not select delete files, just Added, Copied, Modified, Renamed,
# or Type changed # or Type changed
@ -366,16 +368,18 @@ def validate_individual_files(rootdir, exceptions, verbose,
if (base_f == "pom.xml" or if (base_f == "pom.xml" or
base_f in exceptions): base_f in exceptions):
continue continue
any_failures = validate_one_file( any_failures = validate_one_file(schema, rootdir, f, verbose,
schema, rootdir, f, verbose, any_failures, check_syntax, check_niceness)
check_syntax, check_niceness) if any_failures:
no_failed = no_failed + 1
no_validated = no_validated + 1 no_validated = no_validated + 1
if voting and any_failures: if no_failed > 0:
print("Check failed, validated %d xml files.\n" % no_validated) print("Check failed, validated %d xml files with %d failures.\n" % (no_validated, no_failed))
sys.exit(1) if voting:
sys.exit(1)
print("Check passed, validated %d xml files.\n" % no_validated) else:
print("Check passed, validated %d xml files.\n" % no_validated)
def validate_all_files(rootdir, exceptions, verbose, def validate_all_files(rootdir, exceptions, verbose,
@ -383,8 +387,8 @@ def validate_all_files(rootdir, exceptions, verbose,
"""Validate all xml files.""" """Validate all xml files."""
schema = get_schema() schema = get_schema()
any_failures = False
no_validated = 0 no_validated = 0
no_failed = 0
if check_syntax and check_niceness: if check_syntax and check_niceness:
print("Checking syntax and niceness of all xml files...") print("Checking syntax and niceness of all xml files...")
elif check_syntax: elif check_syntax:
@ -408,14 +412,18 @@ def validate_all_files(rootdir, exceptions, verbose,
f not in exceptions): f not in exceptions):
path = os.path.abspath(os.path.join(root, f)) path = os.path.abspath(os.path.join(root, f))
any_failures = validate_one_file( any_failures = validate_one_file(
schema, rootdir, path, verbose, any_failures, schema, rootdir, path, verbose,
check_syntax, check_niceness) check_syntax, check_niceness)
if any_failures:
no_failed = no_failed + 1
no_validated = no_validated + 1 no_validated = no_validated + 1
if voting and any_failures: if no_failed > 0:
print("Check failed, validated %d xml files.\n" % no_validated) print("Check failed, validated %d xml files with %d failures.\n" % (no_validated, no_failed))
sys.exit(1) if voting:
print("Check passed, validated %d xml files.\n" % no_validated) sys.exit(1)
else:
print("Check passed, validated %d xml files.\n" % no_validated)
def logging_build_book(result): def logging_build_book(result):
@ -589,7 +597,7 @@ def build_affected_books(rootdir, book_exceptions, file_exceptions,
maxjobs = 4 maxjobs = 4
pool = multiprocessing.Pool(maxjobs) pool = multiprocessing.Pool(maxjobs)
print("Queuing the following books for building:") print("Queuing the following books for building:")
for book in books: for book in sorted(books):
print(" %s" % os.path.basename(book)) print(" %s" % os.path.basename(book))
pool.apply_async(build_book, (book, ), pool.apply_async(build_book, (book, ),
callback=logging_build_book) callback=logging_build_book)
@ -607,9 +615,12 @@ def build_affected_books(rootdir, book_exceptions, file_exceptions,
% (book, returncode)) % (book, returncode))
print("\n%s" % output) print("\n%s" % output)
if voting and any_failures: if any_failures:
sys.exit(1) print("Building of books finished with failures.\n")
print("Building finished.") if voting:
sys.exit(1)
else:
print("Building of books finished successfully.\n")
def main(args): def main(args):
@ -621,7 +632,7 @@ def main(args):
args.check_niceness = True args.check_niceness = True
if not args.force and only_www_touched(): if not args.force and only_www_touched():
print("Only files in www directory changed, nothing to do.") print("Only files in www directory changed, nothing to do.\n")
return return
if args.check_deletions: if args.check_deletions: