Clarify output from rewrite_includes assertion.

Previously, the conflicting header names were printed between several
lines of "boilerplate" text, and without any explanatory text. This
made them difficult to notice. The assertion now has an explanatory
message and prints the conflicting filenames directly at the point of
the assertion.

Before:
---
Running presubmit upload checks ...
tests/sksl/dslfp GrSwizzle.h /Users/johnstiles/skia/src/gpu/GrSwizzle.h
Traceback (most recent call last):
  File "tools/rewrite_includes.py", line 60, in <module>
    assert file_name not in headers
AssertionError

** Presubmit ERRORS ** (etc)
username$ _

After:
---
Running presubmit upload checks ...
Traceback (most recent call last):
  File "tools/rewrite_includes.py", line 61, in <module>
    assert file_name not in headers, message
AssertionError: Header filename is used more than once!
- tests/sksl/dslfp/GrSwizzle.h
- /Users/johnstiles/skia/src/gpu/GrSwizzle.h

** Presubmit ERRORS ** (etc)
username$ _

Change-Id: I2b6848ef82c4b1c6d4b5577a76969785e5e122bb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/397149
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
This commit is contained in:
John Stiles 2021-04-15 14:45:59 -04:00 committed by Skia Commit-Bot
parent 3910bc9b4c
commit f35853a4a2

View File

@ -56,8 +56,9 @@ for root in roots:
for file_name in files:
if file_name.endswith('.h'):
if file_name in headers:
print(path, file_name, headers[file_name])
assert file_name not in headers
message = ('Header filename is used more than once!\n- ' + path + '/' + file_name +
'\n- ' + headers[file_name])
assert file_name not in headers, message
headers[file_name] = os.path.abspath(os.path.join(path, file_name))
def to_rewrite():