================
@@ -0,0 +1,323 @@
+#!/usr/bin/env python3
+"""Convert 'not llvm-mc ... 2>&1 | FileCheck' tests to 'llvm-mc --verify'.
+
+This only handles simple tests whose FileCheck lines already check every
+diagnostic llvm-mc emits. Since --verify (unlike FileCheck) requires every
+diagnostic to be matched, other tests will fail after conversion and need
+the missing expected-* directives added by hand.
+
+Tests are rewritten in place. Directories are searched recursively for test
+files. Run the converted tests with llvm-lit afterwards and fix up or revert
+any failures.
+"""
+
+from __future__ import annotations
+
+import argparse
+from dataclasses import dataclass
+import pathlib
+import re
+import shlex
+import sys
+
+from UpdateTestChecks import common
+
+sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent / "lit"))
+from lit.ShCommands import Command, Pipeline
+from lit.ShUtil import ShParser
+from lit.TestRunner import CommandDirective, parseIntegratedTestScriptCommands
+
+TEST_SUFFIXES = {".s", ".S", ".asm", ".txt", ".test"}
+# The body of a diagnostic check, e.g. ':[[@LINE-1]]:11: error: message'.
+DIAG_RE = re.compile(
+ r"""
+ (?:
+ (?P<unknown><unknown>:0:\s*)
+ |
+ (?P<file><stdin>|[^\s:\[\d][^\s:\[]*)?:? # Optional filename
+ (?:
+ \[\[\#?\s*@LINE(?P<offset>[+-]\d+)?\]\] # [[@LINE]] or [[#@LINE+N]]
+ | \[\[\#\]\] # [[#]]
+ | \{\{\[0-9\]\+\}\} # {{[0-9]+}}
+ | \b(?P<line>\d+) # Fixed line number
+ ):
+ (?:
+ (?:
+ (?P<col>\d+) # Fixed column number
+ | \[\[\#\]\] # [[#]]
+ | \{\{[^}:\s]+\}\} # Regex column, e.g.
{{[0-9]+}}
+ ):
+ )?\s*
+ )?
+ (?:(?P<kind>error|warning|note|remark):\s*)?
+ (?P<msg>.+?)
+ (?:\{\{\$\}\})? # Optional end-of-line
{{$}}
----------------
topperc wrote:
Does -verify check the whole diagnostic? Do we lose anything by dropping the
end of line check?
https://github.com/llvm/llvm-project/pull/238216
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits