diff --git a/libcxx/utils/libcxx/test/dsl.py b/libcxx/utils/libcxx/test/dsl.py --- a/libcxx/utils/libcxx/test/dsl.py +++ b/libcxx/utils/libcxx/test/dsl.py @@ -20,6 +20,8 @@ import lit.TestRunner import lit.util +class ConfigurationError(Exception): + pass def _memoizeExpensiveOperation(extractCacheKey): """ @@ -105,7 +107,7 @@ with _makeConfigTest(config) as test: with open(test.getSourcePath(), 'w') as sourceFile: sourceFile.write(source) - out, err, exitCode, timeoutInfo = _executeScriptInternal(test, ['%{build}']) + _, _, exitCode, _ = _executeScriptInternal(test, ['%{build}']) _executeScriptInternal(test, ['rm %t.exe']) return exitCode == 0 @@ -115,9 +117,9 @@ Compiles a program for the test target, run it on the test target and return the output. - If the program fails to compile or run, None is returned instead. Note that - execution of the program is done through the %{exec} substitution, which means - that the program may be run on a remote host depending on what %{exec} does. + Note that execution of the program is done through the %{exec} substitution, + which means that the program may be run on a remote host depending on what + %{exec} does. """ if args is None: args = [] @@ -125,13 +127,13 @@ with open(test.getSourcePath(), 'w') as source: source.write(program) try: - _, _, exitCode, _ = _executeScriptInternal(test, ['%{build}']) + _, err, exitCode, _ = _executeScriptInternal(test, ['%{build}']) if exitCode != 0: - return None + raise ConfigurationError("Failed to build program, stderr is:\n{}".format(err)) out, err, exitCode, _ = _executeScriptInternal(test, ["%{{run}} {}".format(' '.join(args))]) if exitCode != 0: - return None + raise ConfigurationError("Failed to run program, stderr is:\n{}".format(err)) actualOut = re.search("# command output:\n(.+)\n$", out, flags=re.DOTALL) actualOut = actualOut.group(1) if actualOut else "" @@ -194,20 +196,17 @@ If the optional `flags` argument (a string) is provided, these flags will be added to the compiler invocation when generating the macros. - - If we fail to extract the compiler macros because of a compiler error, None - is returned instead. """ with _makeConfigTest(config) as test: with open(test.getSourcePath(), 'w') as sourceFile: # Make sure files like <__config> are included, since they can define # additional macros. sourceFile.write("#include ") - unparsedOutput, err, exitCode, timeoutInfo = _executeScriptInternal(test, [ + unparsedOutput, err, exitCode, _ = _executeScriptInternal(test, [ "%{{cxx}} %s -dM -E %{{flags}} %{{compile_flags}} {}".format(flags) ]) if exitCode != 0: - return None + raise ConfigurationError("Failed to retrieve compiler macros, stderr is:\n{}".format(err)) parsedMacros = dict() defines = (l.strip() for l in unparsedOutput.split('\n') if l.startswith('#define ')) for line in defines: