Skip to content

Commit

Permalink
Make test_symbols.py compare files line-by-line
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Ivan Zhechev authored and kiranchandramohan committed Aug 20, 2021
1 parent 3a244fc commit 0d1a0f7
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions flang/test/Semantics/test_symbols.py
Expand Up @@ -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
Expand Down Expand Up @@ -44,9 +44,8 @@
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(" ", ""))
Expand Down

0 comments on commit 0d1a0f7

Please sign in to comment.