[llvm] 725a21b - Reland "[lit] Stop supporting triple substrings in UNSUPPORTED and

Paul Robinson via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 19 13:26:49 PST 2023


Author: Paul Robinson
Date: 2023-01-19T13:26:40-08:00
New Revision: 725a21b62c2de4237712d53f5b34e48400e760b3

URL: https://github.com/llvm/llvm-project/commit/725a21b62c2de4237712d53f5b34e48400e760b3
DIFF: https://github.com/llvm/llvm-project/commit/725a21b62c2de4237712d53f5b34e48400e760b3.diff

LOG: Reland "[lit] Stop supporting triple substrings in UNSUPPORTED and
XFAIL"

This reverts commit 2f8b920f95aa1e308193cf5803df7912025e8400.

Forgot to update lit's own tests.

Added: 
    

Modified: 
    llvm/docs/ReleaseNotes.rst
    llvm/utils/lit/lit/BooleanExpression.py
    llvm/utils/lit/lit/Test.py
    llvm/utils/lit/tests/Inputs/shtest-format/unsupported-expr-true.txt
    llvm/utils/lit/tests/Inputs/shtest-format/xfail-expr-false.txt
    llvm/utils/lit/tests/Inputs/shtest-format/xfail-expr-true.txt
    llvm/utils/lit/tests/Inputs/shtest-format/xpass.txt

Removed: 
    


################################################################################
diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 6dc2dad13ad9..783e8f5617fe 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -309,6 +309,13 @@ Changes to Sanitizers
 Other Changes
 -------------
 
+* lit no longer supports using substrings of the default target triple as
+  feature names in ``UNSUPPORTED:`` and ``XFAIL:`` directives. These have been
+  replaced by the ``target=<triple>`` feature, and tests can use regex
+  matching to achieve the same effect. For example, ``UNSUPPORTED: arm``
+  would now be ``UNSUPPORTED: target=arm{{.*}}`` and ``XFAIL: windows``
+  would now be ``XFAIL: target={{.*}}-windows{{.*}}``.
+
 External Open Source Projects Using LLVM 15
 ===========================================
 

diff  --git a/llvm/utils/lit/lit/BooleanExpression.py b/llvm/utils/lit/lit/BooleanExpression.py
index ff5352778e99..ba8453d60e98 100644
--- a/llvm/utils/lit/lit/BooleanExpression.py
+++ b/llvm/utils/lit/lit/BooleanExpression.py
@@ -22,24 +22,22 @@ class BooleanExpression:
     #
     # Variables in `variables` are true.
     # Regexes that match any variable in `variables` are true.
-    # Substrings of `triple` are true.
     # 'true' is true.
     # All other identifiers are false.
     @staticmethod
-    def evaluate(string, variables, triple=""):
+    def evaluate(string, variables):
         try:
-            parser = BooleanExpression(string, set(variables), triple)
+            parser = BooleanExpression(string, set(variables))
             return parser.parseAll()
         except ValueError as e:
             raise ValueError(str(e) + ('\nin expression: %r' % string))
 
     #####
 
-    def __init__(self, string, variables, triple=""):
+    def __init__(self, string, variables):
         self.tokens = BooleanExpression.tokenize(string)
         self.variables = variables
         self.variables.add('true')
-        self.triple = triple
         self.value = None
         self.token = None
 
@@ -101,7 +99,7 @@ def parseMATCH(self):
             else:
                 regex += re.escape(part)
         regex = re.compile(regex)
-        self.value = self.token in self.triple or any(regex.fullmatch(var) for var in self.variables)
+        self.value = any(regex.fullmatch(var) for var in self.variables)
         self.token = next(self.tokens)
 
     def parseNOT(self):
@@ -174,20 +172,6 @@ def test_variables(self):
         self.assertFalse(BooleanExpression.evaluate('tru', variables))
         self.assertFalse(BooleanExpression.evaluate('{{its-true.+}}', variables))
 
-    def test_triple(self):
-        triple = 'arch-vendor-os'
-        self.assertTrue(BooleanExpression.evaluate('arch-', {}, triple))
-        self.assertTrue(BooleanExpression.evaluate('ar', {}, triple))
-        self.assertTrue(BooleanExpression.evaluate('ch-vend', {}, triple))
-        self.assertTrue(BooleanExpression.evaluate('-vendor-', {}, triple))
-        self.assertTrue(BooleanExpression.evaluate('-os', {}, triple))
-        self.assertFalse(BooleanExpression.evaluate('arch-os', {}, triple))
-
-        # When matching against the triple, a regex is treated as an identifier and checked
-        # for a literal match. This preserves existing behavior before regexes were introduced.
-        self.assertFalse(BooleanExpression.evaluate('arch-{{vendor}}-os', {}, triple))
-        self.assertTrue(BooleanExpression.evaluate('arch-{{vendor}}-os', {}, 'arch-{{vendor}}-os'))
-
     def test_matching(self):
         expr1 = 'linux && (target={{aarch64-.+}} || target={{x86_64-.+}})'
         self.assertTrue(BooleanExpression.evaluate(expr1, {'linux', 'target=x86_64-unknown-linux-gnu'}))

diff  --git a/llvm/utils/lit/lit/Test.py b/llvm/utils/lit/lit/Test.py
index dc1c66e896c5..6c72359440b9 100644
--- a/llvm/utils/lit/lit/Test.py
+++ b/llvm/utils/lit/lit/Test.py
@@ -227,9 +227,9 @@ def __init__(self, suite, path_in_suite, config, file_path = None, gtest_json_fi
         self.gtest_json_file = gtest_json_file
 
         # A list of conditions under which this test is expected to fail.
-        # Each condition is a boolean expression of features and target
-        # triple parts. These can optionally be provided by test format
-        # handlers, and will be honored when the test result is supplied.
+        # Each condition is a boolean expression of features, or '*'.
+        # These can optionally be provided by test format handlers,
+        # and will be honored when the test result is supplied.
         self.xfails = []
 
         # If true, ignore all items in self.xfails.
@@ -238,12 +238,11 @@ def __init__(self, suite, path_in_suite, config, file_path = None, gtest_json_fi
         # A list of conditions that must be satisfied before running the test.
         # Each condition is a boolean expression of features. All of them
         # must be True for the test to run.
-        # FIXME should target triple parts count here too?
         self.requires = []
 
         # A list of conditions that prevent execution of the test.
-        # Each condition is a boolean expression of features and target
-        # triple parts. All of them must be False for the test to run.
+        # Each condition is a boolean expression of features. All of them
+        # must be False for the test to run.
         self.unsupported = []
 
         # An optional number of retries allowed before the test finally succeeds.
@@ -317,18 +316,16 @@ def isExpectedToFail(self):
           return False
 
         features = self.config.available_features
-        triple = getattr(self.suite.config, 'target_triple', "")
 
-        # Check if any of the xfails match an available feature or the target.
+        # Check if any of the xfails match an available feature.
         for item in self.xfails:
             # If this is the wildcard, it always fails.
             if item == '*':
                 return True
 
-            # If this is a True expression of features and target triple parts,
-            # it fails.
+            # If this is a True expression of features, it fails.
             try:
-                if BooleanExpression.evaluate(item, features, triple):
+                if BooleanExpression.evaluate(item, features):
                     return True
             except ValueError as e:
                 raise ValueError('Error in XFAIL list:\n%s' % str(e))
@@ -385,16 +382,15 @@ def getUnsupportedFeatures(self):
         getUnsupportedFeatures() -> list of strings
 
         Returns a list of features from UNSUPPORTED that are present
-        in the test configuration's features or target triple.
+        in the test configuration's features.
         Throws ValueError if an UNSUPPORTED line has a syntax error.
         """
 
         features = self.config.available_features
-        triple = getattr(self.suite.config, 'target_triple', "")
 
         try:
             return [item for item in self.unsupported
-                    if BooleanExpression.evaluate(item, features, triple)]
+                    if BooleanExpression.evaluate(item, features)]
         except ValueError as e:
             raise ValueError('Error in UNSUPPORTED list:\n%s' % str(e))
 

diff  --git a/llvm/utils/lit/tests/Inputs/shtest-format/unsupported-expr-true.txt b/llvm/utils/lit/tests/Inputs/shtest-format/unsupported-expr-true.txt
index f48ba7b2c2d2..64c8661ff63c 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-format/unsupported-expr-true.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-format/unsupported-expr-true.txt
@@ -1,4 +1,4 @@
 # UNSUPPORTED with a true clause. Test should not run.
 UNSUPPORTED: false
-UNSUPPORTED: false, false, false, _64-unk && a-present-feature, false
+UNSUPPORTED: false, false, false, target={{.*}}_64-unk{{.*}} && a-present-feature, false
 RUN: false

diff  --git a/llvm/utils/lit/tests/Inputs/shtest-format/xfail-expr-false.txt b/llvm/utils/lit/tests/Inputs/shtest-format/xfail-expr-false.txt
index 83b0de1621d0..27acebf5dd93 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-format/xfail-expr-false.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-format/xfail-expr-false.txt
@@ -1,3 +1,3 @@
 # XFAIL with only false clauses. Test should run.
-XFAIL: false, a-missing-feature || ! a-present-feature || ! x86_64, false
+XFAIL: false, a-missing-feature || ! a-present-feature || ! target=x86_64{{.*}}, false
 RUN: true

diff  --git a/llvm/utils/lit/tests/Inputs/shtest-format/xfail-expr-true.txt b/llvm/utils/lit/tests/Inputs/shtest-format/xfail-expr-true.txt
index 3c197484897e..0a210a9bee47 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-format/xfail-expr-true.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-format/xfail-expr-true.txt
@@ -1,4 +1,4 @@
 # XFAIL with a true clause. Test should not run.
 XFAIL: false
-XFAIL: false, a-present-feature && ! a-missing-feature && x86_64
+XFAIL: false, a-present-feature && ! a-missing-feature && target=x86_64{{.*}}
 RUN: false

diff  --git a/llvm/utils/lit/tests/Inputs/shtest-format/xpass.txt b/llvm/utils/lit/tests/Inputs/shtest-format/xpass.txt
index 764d21798b37..37bd5bbcb169 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-format/xpass.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-format/xpass.txt
@@ -1,2 +1,2 @@
 RUN: true
-XFAIL: x86_64
+XFAIL: target=x86_64{{.*}}


        


More information about the llvm-commits mailing list