[libcxx-commits] [PATCH] D103311: [libcxx] [test] Fix the _supportsVerify check on Windows by using hasCompileFlag

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri May 28 04:26:47 PDT 2021


mstorsjo created this revision.
mstorsjo added a reviewer: ldionne.
Herald added subscribers: tschuett, arichardson.
mstorsjo requested review of this revision.
Herald added a project: libc++.
Herald added a reviewer: libc++.

The %{cxx} substitution can be quoted with single quotes, which is
fine with unix shells and when executing commands with the lit
internal shell, but breaks when executed directly with subprocess.call()
on Windows.

(The alternative would be to fix the quoting of the subsitution, but
that turns out to be a deeper rabbit hole than expected.)

This also has the side effect of reducing the number of calls to
the compiler, as the hasCompileFlag method is cached.

This unlocks 114 tests that previously were skipped on Windows.

This is a much more straightforward alternative to D103310 <https://reviews.llvm.org/D103310>; it doesn't
address the issue of the way those strings are quoted though, but
avoids that being an issue.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103311

Files:
  libcxx/utils/libcxx/test/format.py


Index: libcxx/utils/libcxx/test/format.py
===================================================================
--- libcxx/utils/libcxx/test/format.py
+++ libcxx/utils/libcxx/test/format.py
@@ -6,6 +6,7 @@
 #
 #===----------------------------------------------------------------------===##
 
+from libcxx.test.dsl import *
 import lit
 import lit.formats
 import os
@@ -21,12 +22,7 @@
     This is done by checking whether the %{cxx} substitution in that
     configuration supports certain compiler flags.
     """
-    command = "%{{cxx}} -xc++ {} -Werror -fsyntax-only -Xclang -verify-ignore-unexpected".format(os.devnull)
-    command = lit.TestRunner.applySubstitutions([command], config.substitutions,
-                                                recursion_limit=config.recursiveExpansionLimit)[0]
-    devNull = open(os.devnull, 'w')
-    result = subprocess.call(command, shell=True, stdout=devNull, stderr=devNull)
-    return result == 0
+    return hasCompileFlag(config, '-Xclang -verify-ignore-unexpected')
 
 def _getTempPaths(test):
     """


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103311.348492.patch
Type: text/x-patch
Size: 1059 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210528/72a7672b/attachment.bin>


More information about the libcxx-commits mailing list