[llvm] [lit] Add JSON diffing support to lit (PR #177513)
Henrik G. Olsson via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 6 20:04:25 PST 2026
================
@@ -2,76 +2,291 @@
import sys
import difflib
import getopt
+import re
-
-class CommandLineArguments:
- def __init__(self):
- self.ignore_extra_keys = False
- self.context = 3
- self.expected_file = None
- self.actual_file = None
+# ==============================================================================
+# Utility Functions
+# ==============================================================================
-def fail(msg, exit_code):
- sys.stderr.write(msg)
- sys.stderr.write("\n")
+def fail(exit_code, *messages):
+ """Print error messages to stderr and exit with the given code."""
+ for msg in messages:
+ sys.stderr.write(msg)
+ sys.stderr.write("\n")
sys.exit(exit_code)
-def readJson(filepath):
- def checkDuplicateKeys(pairs):
- keys = [key for (key, value) in pairs]
- seen = set()
- duplicates = set()
+# ==============================================================================
+# Match Result Classes
+# ==============================================================================
- for key in keys:
- if key in seen:
- duplicates.add(key)
+
+class MatchResult:
----------------
hnrklssn wrote:
How well does this work with the context of a mismatch? If I have a 200 line JSON, will I be able to easily find which field the mismatch was on?
https://github.com/llvm/llvm-project/pull/177513
More information about the llvm-commits
mailing list