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 @@ 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]