[libcxx-commits] [libcxx] 43270c6 - [libc++] Verify base substitutions earlier in the testing format
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Sep 21 12:30:42 PDT 2020
Author: Louis Dionne
Date: 2020-09-21T15:30:29-04:00
New Revision: 43270c65cf48484d8b8cee5044480f6f1b00281d
URL: https://github.com/llvm/llvm-project/commit/43270c65cf48484d8b8cee5044480f6f1b00281d
DIFF: https://github.com/llvm/llvm-project/commit/43270c65cf48484d8b8cee5044480f6f1b00281d.diff
LOG: [libc++] Verify base substitutions earlier in the testing format
This allows diagnosing missing substitution issues even when doing
availability feature detection in the DSL.
Added:
Modified:
libcxx/utils/libcxx/test/format.py
Removed:
################################################################################
diff --git a/libcxx/utils/libcxx/test/format.py b/libcxx/utils/libcxx/test/format.py
index 4390166ca6bf..53336175bec3 100644
--- a/libcxx/utils/libcxx/test/format.py
+++ b/libcxx/utils/libcxx/test/format.py
@@ -41,6 +41,11 @@ def _getTempPaths(test):
tmpBase = os.path.join(tmpDir, 't')
return tmpDir, tmpBase
+def _checkBaseSubstitutions(substitutions):
+ substitutions = [s for (s, _) in substitutions]
+ for s in ['%{cxx}', '%{compile_flags}', '%{link_flags}', '%{flags}', '%{exec}']:
+ assert s in substitutions, "Required substitution {} was not provided".format(s)
+
def parseScript(test, preamble):
"""
Extract the script from a test, with substitutions applied.
@@ -63,7 +68,8 @@ def parseScript(test, preamble):
substitutions = lit.TestRunner.getDefaultSubstitutions(test, tmpDir, tmpBase,
normalize_slashes=useExternalSh)
- # Add the %{build} and %{run} convenience substitutions
+ # Check base substitutions and add the %{build} and %{run} convenience substitutions
+ _checkBaseSubstitutions(substitutions)
substitutions.append(('%{build}', '%{cxx} %s %{flags} %{compile_flags} %{link_flags} -o %t.exe'))
substitutions.append(('%{run}', '%{exec} %t.exe'))
@@ -207,18 +213,12 @@ def getTestsInDirectory(self, testSuite, pathInSuite, litConfig, localConfig):
if any([re.search(ext, filename) for ext in SUPPORTED_SUFFIXES]):
yield lit.Test.Test(testSuite, pathInSuite + (filename,), localConfig)
- def _checkBaseSubstitutions(self, substitutions):
- substitutions = [s for (s, _) in substitutions]
- for s in ['%{cxx}', '%{compile_flags}', '%{link_flags}', '%{flags}', '%{exec}']:
- assert s in substitutions, "Required substitution {} was not provided".format(s)
-
def _disableWithModules(self, test):
with open(test.getSourcePath(), 'rb') as f:
contents = f.read()
return b'#define _LIBCPP_ASSERT' in contents
def execute(self, test, litConfig):
- self._checkBaseSubstitutions(test.config.substitutions)
VERIFY_FLAGS = '-Xclang -verify -Xclang -verify-ignore-unexpected=note -ferror-limit=0'
supportsVerify = _supportsVerify(test.config)
filename = test.path_in_suite[-1]
More information about the libcxx-commits
mailing list