Skip to content

Commit

Permalink
Manual diff
Browse files Browse the repository at this point in the history
  • Loading branch information
ldionne committed Sep 30, 2024
1 parent 8ffef49 commit 5fb01b1
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
2 changes: 1 addition & 1 deletion libcxx/test/libcxx/transitive_includes.gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
// RUN: %{{cxx}} %s %{{flags}} %{{compile_flags}} --trace-includes -fshow-skipped-includes --preprocess > /dev/null 2> %t/trace-includes.txt
// RUN: %{{python}} %{{libcxx-dir}}/test/libcxx/transitive_includes/to_csv.py %t/trace-includes.txt > %t/actual_transitive_includes.csv
// RUN: %{{python}} %{{libcxx-dir}}/test/libcxx/transitive_includes/expected.py %{{cxx_std}} "{header}" %t/expected_transitive_includes.csv
// RUN: diff %t/expected_transitive_includes.csv %t/actual_transitive_includes.csv
// RUN: %{{python}} %{{libcxx-dir}}/test/libcxx/transitive_includes/diff.py %t/expected_transitive_includes.csv %t/actual_transitive_includes.csv
#include <{header}>
"""
)
36 changes: 36 additions & 0 deletions libcxx/test/libcxx/transitive_includes/diff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env python
# ===----------------------------------------------------------------------===##
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
# ===----------------------------------------------------------------------===##

import argparse
import os
import sys

if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="""Diff two files.""",
)
parser.add_argument("file1", default=None)
parser.add_argument("file2", default=None)
args = parser.parse_args()

def doread(f):
with open(f, 'r') as file:
content = file.read()
lines = [l.strip() for l in content.splitlines()]
return list(filter(None, lines))

content1 = doread(args.file1)
content2 = doread(args.file2)

for l1, l2 in zip(content1, content2):
if l1 != l2:
print("line not equal")
print(l1)
print(l2)
sys.exit(1)
4 changes: 2 additions & 2 deletions libcxx/test/libcxx/transitive_includes/expected.py
Original file line number Diff line number Diff line change
Expand Up @@ -2681,11 +2681,11 @@
for line in files[args.standard].splitlines():
# print(f"READING LINE: {line}")
if line.startswith(args.header + ' '):
print(f"WRITING THIS TO OUTPUT: {line}\n")
# print(f"WRITING THIS TO OUTPUT: {line}\n")
output.write(line + '\n')

with open(args.out, 'r') as output:
print("WRITTEN OUTPUT IS:")
# print("WRITTEN OUTPUT IS:")
print(output.read())

# CSV_ROOT = os.path.dirname(__file__)
Expand Down

0 comments on commit 5fb01b1

Please sign in to comment.