forked from OSchip/llvm-project
Make test_symbols.py compare files line-by-line
We currently feed full files to Python's unified_diff. It's not quite what we want though - line-by-line comparison makes more sense (we want to be able to identify missing/unnecessary lines) and is also easier to parse for humans. This patch makes sure that we compare one line at a time. This change pretties up the output formatting in the script. Output before: ``` !DEF:/m/s/xINTENT(IN)(Implicit)ObjectEntityREAL(4) !DEF:/m/s/yINTENT(INOUT)(Implicit)ObjectEntityREAL(4) -!-D-E-F-:-f-o-o-b-a-r- puresubroutines(x,y)bind(c) !REF:/m/s/x intent(in)::x ``` Proposed output after: ``` !DEF:/m/s/xINTENT(IN)(Implicit)ObjectEntityREAL(4) !DEF:/m/s/yINTENT(INOUT)(Implicit)ObjectEntityREAL(4) -!DEF:foobar puresubroutines(x,y)bind(c) !REF:/m/s/x intent(in)::x ``` Reviewed By: Meinersbur, awarzynski Differential Revision: https://reviews.llvm.org/D107954
This commit is contained in:
parent
3a244fcf29
commit
0d1a0f7e8d
|
@ -4,7 +4,7 @@
|
|||
we get the right symbols in the output, i.e. the output should be
|
||||
the same as the input, except for the copyright comment.
|
||||
Expects a source file passed as the first argument;
|
||||
Expects the Flang frontdriver with options as second argument."""
|
||||
Expects the Flang frontend driver with options as second argument."""
|
||||
|
||||
import sys
|
||||
import re
|
||||
|
@ -44,9 +44,8 @@ diff3 = diff3.replace(" ", "")
|
|||
diff_check = ""
|
||||
|
||||
# Compares the input with the output
|
||||
for line in unified_diff(diff1, diff3, n=999999,
|
||||
fromfile="Expected output", tofile="Actual output"):
|
||||
diff_check += line
|
||||
diff_check = "\n".join(unified_diff(diff1.split("\n"), diff3.split("\n"), n=999999,
|
||||
fromfile="Expected_output", tofile="Actual_output"))
|
||||
|
||||
if diff_check != "":
|
||||
print(diff_check.replace(" ", ""))
|
||||
|
|
Loading…
Reference in New Issue