| 1 |
#!/usr/bin/env python3 |
| 2 |
# SPDX-License-Identifier: Apache-2.0 |
| 3 |
# Copyright © 2024 Intel Corporation |
| 4 |
|
| 5 |
import argparse |
| 6 |
import sys |
| 7 |
import difflib |
| 8 |
|
| 9 |
|
| 10 |
def main() -> int: |
| 11 |
parser = argparse.ArgumentParser() |
| 12 |
parser.add_argument('actual', help='The transformed contents') |
| 13 |
parser.add_argument('expected', help='the contents we expected') |
| 14 |
args = parser.parse_args() |
| 15 |
|
| 16 |
with open(args.actual, 'r', encoding='utf-8') as f: |
| 17 |
actual = f.readlines() |
| 18 |
with open(args.expected, 'r', encoding='utf-8') as f: |
| 19 |
expected = f.readlines() |
| 20 |
|
| 21 |
if actual == expected: |
| 22 |
return 0 |
| 23 |
|
| 24 |
diff = difflib.ndiff(expected, actual) |
| 25 |
for line in diff: |
| 26 |
print(line, file=sys.stderr, end='') |
| 27 |
return 1 |
| 28 |
|
| 29 |
|
| 30 |
if __name__ == "__main__": |
| 31 |
sys.exit(main()) |