[libc++] Verify base substitutions earlier in the testing format

This allows diagnosing missing substitution issues even when doing
availability feature detection in the DSL.
This commit is contained in:
Louis Dionne 2020-09-21 15:27:40 -04:00
parent f4f7df037e
commit 43270c65cf
1 changed files with 7 additions and 7 deletions

View File

@ -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 @@ class CxxStandardLibraryTest(lit.formats.TestFormat):
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]