[libcxx-commits] [libcxx] [libc++] Fixes lit portability issues. (PR #72435)

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Thu Nov 16 01:45:41 PST 2023


https://github.com/mordante updated https://github.com/llvm/llvm-project/pull/72435

>From c029f1bc355c1a0c8f4d81ab5a35fe770aac2e09 Mon Sep 17 00:00:00 2001
From: Mark de Wever <koraq at xs4all.nl>
Date: Wed, 15 Nov 2023 21:34:31 +0100
Subject: [PATCH 1/2] [libc++] Fixes lit portability issues.

@StephanTLavavej mentioned the libc++ tests no longer works for MSVC STL.
The regex changes have been provided by Stephan.
---
 libcxx/test/lit.local.cfg          | 8 +++++++-
 libcxx/utils/libcxx/test/params.py | 4 ++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/libcxx/test/lit.local.cfg b/libcxx/test/lit.local.cfg
index 4116553b6f7a9ae..da214edbccf5a88 100644
--- a/libcxx/test/lit.local.cfg
+++ b/libcxx/test/lit.local.cfg
@@ -29,7 +29,13 @@ def appendToSubstitution(substitutions, key, value):
     return [(k, v + " " + value) if k == key else (k, v) for (k, v) in substitutions]
 
 
-std = getSubstitution("%{cxx_std}", config)
+# External users of the LLVM test suite might not have set the substitutions.
+std = ""
+try:
+    std = getSubstitution("%{cxx_std}", config)
+except:
+    pass
+
 if std == "cxx26":
     std = "26"
 elif std == "cxx23":
diff --git a/libcxx/utils/libcxx/test/params.py b/libcxx/utils/libcxx/test/params.py
index e31130572df6576..3fedbf972c0c822 100644
--- a/libcxx/utils/libcxx/test/params.py
+++ b/libcxx/utils/libcxx/test/params.py
@@ -114,7 +114,7 @@ def getStdFlag(cfg, std):
         ),
         actions=lambda std: [
             AddFeature(std),
-            AddSubstitution("%{cxx_std}", re.sub("\+", "x", std)),
+            AddSubstitution("%{cxx_std}", re.sub(r"\+", "x", std)),
             AddCompileFlag(lambda cfg: getStdFlag(cfg, std)),
         ],
     ),
@@ -187,7 +187,7 @@ def getStdFlag(cfg, std):
                 AddFeature("stdlib={}".format(stdlib)),
                 # Also add an umbrella feature 'stdlib=libc++' for all flavors of libc++, to simplify
                 # the test suite.
-                AddFeature("stdlib=libc++") if re.match(".+-libc\+\+", stdlib) else None,
+                AddFeature("stdlib=libc++") if re.match(r".+-libc\+\+", stdlib) else None,
             ],
         ),
     ),

>From ef1ca583fe16bf4c5e5efe8cf1fcefebb0cec002 Mon Sep 17 00:00:00 2001
From: Mark de Wever <koraq at xs4all.nl>
Date: Thu, 16 Nov 2023 10:45:24 +0100
Subject: [PATCH 2/2] Addresses review comments.

---
 libcxx/test/lit.local.cfg | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/libcxx/test/lit.local.cfg b/libcxx/test/lit.local.cfg
index da214edbccf5a88..4116553b6f7a9ae 100644
--- a/libcxx/test/lit.local.cfg
+++ b/libcxx/test/lit.local.cfg
@@ -29,13 +29,7 @@ def appendToSubstitution(substitutions, key, value):
     return [(k, v + " " + value) if k == key else (k, v) for (k, v) in substitutions]
 
 
-# External users of the LLVM test suite might not have set the substitutions.
-std = ""
-try:
-    std = getSubstitution("%{cxx_std}", config)
-except:
-    pass
-
+std = getSubstitution("%{cxx_std}", config)
 if std == "cxx26":
     std = "26"
 elif std == "cxx23":



More information about the libcxx-commits mailing list