[flang-commits] [flang] 0d1a0f7 - Make test_symbols.py compare files line-by-line

Kiran Chandramohan via flang-commits flang-commits at lists.llvm.org
Fri Aug 20 10:28:50 PDT 2021


Author: Ivan Zhechev
Date: 2021-08-20T18:28:35+01:00
New Revision: 0d1a0f7e8de5a506c0bd409fc27e77fb733f7886

URL: https://github.com/llvm/llvm-project/commit/0d1a0f7e8de5a506c0bd409fc27e77fb733f7886
DIFF: https://github.com/llvm/llvm-project/commit/0d1a0f7e8de5a506c0bd409fc27e77fb733f7886.diff

LOG: 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

Added: 
    

Modified: 
    flang/test/Semantics/test_symbols.py

Removed: 
    


################################################################################
diff  --git a/flang/test/Semantics/test_symbols.py b/flang/test/Semantics/test_symbols.py
index 2ca2301745d0..e284e340267a 100755
--- a/flang/test/Semantics/test_symbols.py
+++ b/flang/test/Semantics/test_symbols.py
@@ -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 @@
 
diff _check = ""
 
 # Compares the input with the output
-for line in unified_
diff (
diff 1, 
diff 3, n=999999,
-                         fromfile="Expected output", tofile="Actual output"):
-    
diff _check += line
+
diff _check = "\n".join(unified_
diff (
diff 1.split("\n"), 
diff 3.split("\n"), n=999999,
+                       fromfile="Expected_output", tofile="Actual_output"))
 
 if 
diff _check != "":
     print(
diff _check.replace(" ", ""))


        


More information about the flang-commits mailing list