[libcxx-commits] [libcxx] b58b61c - [libc++] Remove dead code since the removal of the old testing format
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jun 30 07:08:08 PDT 2020
Author: Louis Dionne
Date: 2020-06-30T10:07:59-04:00
New Revision: b58b61c4b78ce81a4ef974374c707163b3691bfe
URL: https://github.com/llvm/llvm-project/commit/b58b61c4b78ce81a4ef974374c707163b3691bfe
DIFF: https://github.com/llvm/llvm-project/commit/b58b61c4b78ce81a4ef974374c707163b3691bfe.diff
LOG: [libc++] Remove dead code since the removal of the old testing format
Added:
Modified:
libcxx/utils/libcxx/test/config.py
Removed:
libcxx/test/libcxx/selftest/exec.sh.cpp
libcxx/test/libcxx/selftest/test.arc.pass.mm
libcxx/test/libcxx/selftest/test.pass.cpp
libcxx/test/libcxx/selftest/test.pass.mm
libcxx/test/libcxx/selftest/test.sh.cpp
libcxx/utils/libcxx/test/executor.py
libcxx/utils/libcxx/test/format.py
libcxx/utils/libcxx/test/tracing.py
################################################################################
diff --git a/libcxx/test/libcxx/selftest/exec.sh.cpp b/libcxx/test/libcxx/selftest/exec.sh.cpp
deleted file mode 100644
index 19c3d590978b..000000000000
--- a/libcxx/test/libcxx/selftest/exec.sh.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// RUN: %{build}
-// RUN: %{exec} %t.exe "HELLO"
-
-#include <cassert>
-#include <string>
-
-int main(int argc, char** argv) {
- assert(argc == 2);
-
- std::string arg = argv[1];
- assert(arg == "HELLO");
- return 0;
-}
diff --git a/libcxx/test/libcxx/selftest/test.arc.pass.mm b/libcxx/test/libcxx/selftest/test.arc.pass.mm
deleted file mode 100644
index b70b24e63183..000000000000
--- a/libcxx/test/libcxx/selftest/test.arc.pass.mm
+++ /dev/null
@@ -1,17 +0,0 @@
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// REQUIRES: has-fobjc-arc
-// ADDITIONAL_COMPILE_FLAGS: -fobjc-arc
-
-#if __has_feature(objc_arc) == 0
-#error "arc should be enabled"
-#endif
-
-int main(int, char**) { return 0; }
diff --git a/libcxx/test/libcxx/selftest/test.pass.cpp b/libcxx/test/libcxx/selftest/test.pass.cpp
deleted file mode 100644
index 779762e7e995..000000000000
--- a/libcxx/test/libcxx/selftest/test.pass.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-int main(int, char**)
-{
-
- return 0;
-}
diff --git a/libcxx/test/libcxx/selftest/test.pass.mm b/libcxx/test/libcxx/selftest/test.pass.mm
deleted file mode 100644
index 2475c31e1895..000000000000
--- a/libcxx/test/libcxx/selftest/test.pass.mm
+++ /dev/null
@@ -1,16 +0,0 @@
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// REQUIRES: objective-c++
-
-#if __has_feature(objc_arc)
-#error "arc should *not* be enabled"
-#endif
-
-int main(int, char**) { return 0; }
diff --git a/libcxx/test/libcxx/selftest/test.sh.cpp b/libcxx/test/libcxx/selftest/test.sh.cpp
deleted file mode 100644
index 5c4db16d84d1..000000000000
--- a/libcxx/test/libcxx/selftest/test.sh.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// RUN: %{build}
-// RUN: %{run}
-
-int main(int, char**)
-{
-
- return 0;
-}
diff --git a/libcxx/utils/libcxx/test/config.py b/libcxx/utils/libcxx/test/config.py
index 27b59e55aeaa..69b01f14d384 100644
--- a/libcxx/utils/libcxx/test/config.py
+++ b/libcxx/utils/libcxx/test/config.py
@@ -18,8 +18,6 @@
from libcxx.compiler import CXXCompiler
from libcxx.test.target_info import make_target_info
-from libcxx.test.executor import *
-from libcxx.test.tracing import *
import libcxx.util
import libcxx.test.features
import libcxx.test.params
diff --git a/libcxx/utils/libcxx/test/executor.py b/libcxx/utils/libcxx/test/executor.py
deleted file mode 100644
index c34310cdd2e2..000000000000
--- a/libcxx/utils/libcxx/test/executor.py
+++ /dev/null
@@ -1,258 +0,0 @@
-#===----------------------------------------------------------------------===##
-#
-# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-# See https://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#
-#===----------------------------------------------------------------------===##
-
-import platform
-import os
-import posixpath
-import ntpath
-import shutil
-
-from libcxx.test import tracing
-from libcxx.util import executeCommand
-
-class Executor(object):
- def __init__(self):
- self.target_info = None
-
- def run(self, exe_path, cmd, local_cwd, file_deps=None, env=None):
- """Execute a command.
- Be very careful not to change shared state in this function.
- Executor objects are shared between python processes in `lit -jN`.
- Args:
- exe_path: str: Local path to the executable to be run
- cmd: [str]: subprocess.call style command
- local_cwd: str: Local path to the working directory
- file_deps: [str]: Files required by the test
- env: {str: str}: Environment variables to execute under
- Returns:
- cmd, out, err, exitCode
- """
- raise NotImplementedError
-
- def merge_environments(self, current_env, updated_env):
- """Merges two execution environments.
-
- If both environments contain the PATH variables, they are also merged
- using the proper separator.
- """
- result_env = dict(current_env)
- for k, v in updated_env.items():
- if k == 'PATH' and self.target_info:
- self.target_info.add_path(result_env, v)
- else:
- result_env[k] = v
- return result_env
-
-
-class LocalExecutor(Executor):
- def __init__(self):
- super(LocalExecutor, self).__init__()
- self.is_windows = platform.system() == 'Windows'
-
- def run(self, exe_path, cmd=None, work_dir='.', file_deps=None, env=None):
- cmd = cmd or [exe_path]
- if work_dir == '.':
- work_dir = os.getcwd()
-
- if env:
- env = self.merge_environments(os.environ, env)
-
- for dep in file_deps:
- if os.path.isdir(dep):
- shutil.copytree(dep, os.path.join(work_dir, os.path.basename(dep)), symlinks=True)
- else:
- shutil.copy2(dep, work_dir)
-
- out, err, rc = executeCommand(cmd, cwd=work_dir, env=env)
- return (cmd, out, err, rc)
-
-
-class PrefixExecutor(Executor):
- """Prefix an executor with some other command wrapper.
-
- Most useful for setting ulimits on commands, or running an emulator like
- qemu and valgrind.
- """
- def __init__(self, commandPrefix, chain):
- super(PrefixExecutor, self).__init__()
-
- self.commandPrefix = commandPrefix
- self.chain = chain
-
- def run(self, exe_path, cmd=None, work_dir='.', file_deps=None, env=None):
- cmd = cmd or [exe_path]
- return self.chain.run(exe_path, self.commandPrefix + cmd, work_dir,
- file_deps, env=env)
-
-
-class PostfixExecutor(Executor):
- """Postfix an executor with some args."""
- def __init__(self, commandPostfix, chain):
- super(PostfixExecutor, self).__init__()
-
- self.commandPostfix = commandPostfix
- self.chain = chain
-
- def run(self, exe_path, cmd=None, work_dir='.', file_deps=None, env=None):
- cmd = cmd or [exe_path]
- return self.chain.run(cmd + self.commandPostfix, work_dir, file_deps,
- env=env)
-
-
-
-class TimeoutExecutor(PrefixExecutor):
- """Execute another action under a timeout.
-
- Deprecated. http://reviews.llvm.org/D6584 adds timeouts to LIT.
- """
- def __init__(self, duration, chain):
- super(TimeoutExecutor, self).__init__(
- ['timeout', duration], chain)
-
-
-class RemoteExecutor(Executor):
- def __init__(self):
- super(RemoteExecutor, self).__init__()
- self.local_run = executeCommand
-
- def remote_temp_dir(self):
- return self._remote_temp(True)
-
- def remote_temp_file(self):
- return self._remote_temp(False)
-
- def _remote_temp(self, is_dir):
- raise NotImplementedError()
-
- def copy_in(self, local_srcs, remote_dsts):
- # This could be wrapped up in a tar->scp->untar for performance
- # if there are lots of files to be copied/moved
- for src, dst in zip(local_srcs, remote_dsts):
- self._copy_in_file(src, dst)
-
- def _copy_in_file(self, src, dst):
- raise NotImplementedError()
-
- def delete_remote(self, remote):
- try:
- self.execute_command_remote(['rm', '-rf', remote])
- except OSError:
- # TODO: Log failure to delete?
- pass
-
- def run(self, exe_path, cmd=None, work_dir='.', file_deps=None, env=None):
- target_exe_path = None
- target_cwd = None
- try:
- target_cwd = self.remote_temp_dir()
- executable_name = 'libcxx_test.exe'
- if self.target_info.is_windows():
- target_exe_path = ntpath.join(target_cwd, executable_name)
- else:
- target_exe_path = posixpath.join(target_cwd, executable_name)
-
- if cmd:
- # Replace exe_path with target_exe_path.
- cmd = [c if c != exe_path else target_exe_path for c in cmd]
- else:
- cmd = [target_exe_path]
-
- srcs = [exe_path]
- dsts = [target_exe_path]
- if file_deps is not None:
- dev_paths = [os.path.join(target_cwd, os.path.basename(f))
- for f in file_deps]
- srcs.extend(file_deps)
- dsts.extend(dev_paths)
- self.copy_in(srcs, dsts)
-
- # When testing executables that were cross-compiled on Windows for
- # Linux, we may need to explicitly set the execution permission to
- # avoid the 'Permission denied' error:
- chmod_cmd = ['chmod', '+x', target_exe_path]
-
- # TODO(jroelofs): capture the copy_in and delete_remote commands,
- # and conjugate them with '&&'s around the first tuple element
- # returned here:
- return self.execute_command_remote(chmod_cmd + ['&&'] + cmd,
- target_cwd,
- env)
- finally:
- if target_cwd:
- self.delete_remote(target_cwd)
-
- def execute_command_remote(self, cmd, remote_work_dir='.', env=None):
- raise NotImplementedError()
-
-
-class SSHExecutor(RemoteExecutor):
- def __init__(self, host, username=None):
- super(SSHExecutor, self).__init__()
-
- self.user_prefix = username + '@' if username else ''
- self.host = host
- self.scp_command = 'scp'
- self.ssh_command = 'ssh'
-
- # TODO(jroelofs): switch this on some -super-verbose-debug config flag
- if False:
- self.local_run = tracing.trace_function(
- self.local_run, log_calls=True, log_results=True,
- label='ssh_local')
-
- def _remote_temp(self, is_dir):
- # TODO: detect what the target system is, and use the correct
- # mktemp command for it. (linux and darwin
diff er here, and I'm
- # sure windows has another way to do it)
-
- # Not sure how to do suffix on osx yet
- dir_arg = '-d' if is_dir else ''
- cmd = 'mktemp -q {} /tmp/libcxx.XXXXXXXXXX'.format(dir_arg)
- _, temp_path, err, exitCode = self.execute_command_remote([cmd])
- temp_path = temp_path.strip()
- if exitCode != 0:
- raise RuntimeError(err)
- return temp_path
-
- def _copy_in_file(self, src, dst):
- scp = self.scp_command
- remote = self.host
- remote = self.user_prefix + remote
- cmd = [scp, '-p', src, remote + ':' + dst]
- self.local_run(cmd)
-
- def _export_command(self, env):
- if not env:
- return []
-
- export_cmd = ['export']
-
- for k, v in env.items():
- v = v.replace('\\', '\\\\')
- if k == 'PATH':
- # Pick up the existing paths, so we don't lose any commands
- if self.target_info and self.target_info.is_windows():
- export_cmd.append('PATH="%s;%PATH%"' % v)
- else:
- export_cmd.append('PATH="%s:$PATH"' % v)
- else:
- export_cmd.append('"%s"="%s"' % (k, v))
-
- return export_cmd
-
- def execute_command_remote(self, cmd, remote_work_dir='.', env=None):
- remote = self.user_prefix + self.host
- ssh_cmd = [self.ssh_command, '-oBatchMode=yes', remote]
- export_cmd = self._export_command(env)
- remote_cmd = ' '.join(cmd)
- if export_cmd:
- remote_cmd = ' '.join(export_cmd) + ' && ' + remote_cmd
- if remote_work_dir != '.':
- remote_cmd = 'cd ' + remote_work_dir + ' && ' + remote_cmd
- out, err, rc = self.local_run(ssh_cmd + [remote_cmd])
- return (remote_cmd, out, err, rc)
diff --git a/libcxx/utils/libcxx/test/format.py b/libcxx/utils/libcxx/test/format.py
deleted file mode 100644
index 207df2322be9..000000000000
--- a/libcxx/utils/libcxx/test/format.py
+++ /dev/null
@@ -1,263 +0,0 @@
-#===----------------------------------------------------------------------===##
-#
-# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-# See https://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#
-#===----------------------------------------------------------------------===##
-
-import copy
-import errno
-import os
-import shutil
-import tempfile
-import time
-import random
-
-import lit.Test # pylint: disable=import-error
-import lit.TestRunner # pylint: disable=import-error
-from lit.TestRunner import ParserKind, IntegratedTestKeywordParser \
- # pylint: disable=import-error
-
-from libcxx.test.executor import LocalExecutor as LocalExecutor
-from libcxx.test.executor import SSHExecutor as SSHExecutor
-import libcxx.util
-
-
-class LibcxxTestFormat(object):
- """
- Custom test format handler for use with the test format use by libc++.
-
- Tests fall into two categories:
- FOO.pass.cpp - Executable test which should compile, run, and exit with
- code 0.
- FOO.fail.cpp - Negative test case which is expected to fail compilation.
- FOO.sh.cpp - A test that uses LIT's ShTest format.
- """
-
- def __init__(self, cxx, use_verify_for_fail,
- executor, exec_env):
- self.cxx = copy.deepcopy(cxx)
- self.use_verify_for_fail = use_verify_for_fail
- self.executor = executor
- self.exec_env = dict(exec_env)
-
- @staticmethod
- def _make_custom_parsers(test):
- return [
- IntegratedTestKeywordParser('FILE_DEPENDENCIES:', ParserKind.LIST,
- initial_value=test.file_dependencies),
- IntegratedTestKeywordParser('ADDITIONAL_COMPILE_FLAGS:', ParserKind.LIST,
- initial_value=[])
- ]
-
- # Utility function to add compile flags in lit.local.cfg files.
- def addCompileFlags(self, config, *flags):
- self.cxx = copy.deepcopy(self.cxx)
- self.cxx.compile_flags += flags
-
- @staticmethod
- def _get_parser(key, parsers):
- for p in parsers:
- if p.keyword == key:
- return p
- assert False and "parser not found"
-
- # TODO: Move this into lit's FileBasedTest
- def getTestsInDirectory(self, testSuite, path_in_suite,
- litConfig, localConfig):
- source_path = testSuite.getSourcePath(path_in_suite)
- for filename in os.listdir(source_path):
- # Ignore dot files and excluded tests.
- if filename.startswith('.') or filename in localConfig.excludes:
- continue
-
- filepath = os.path.join(source_path, filename)
- if not os.path.isdir(filepath):
- if any([filename.endswith(ext)
- for ext in localConfig.suffixes]):
- yield lit.Test.Test(testSuite, path_in_suite + (filename,),
- localConfig)
-
- def execute(self, test, lit_config):
- while True:
- try:
- return self._execute(test, lit_config)
- except OSError as oe:
- if oe.errno != errno.ETXTBSY:
- raise
- time.sleep(0.1)
-
- def _execute(self, test, lit_config):
- name = test.path_in_suite[-1]
- name_root, name_ext = os.path.splitext(name)
- is_libcxx_test = test.path_in_suite[0] == 'libcxx'
- is_sh_test = name_root.endswith('.sh')
- is_pass_test = name.endswith('.pass.cpp') or name.endswith('.pass.mm')
- is_fail_test = name.endswith('.fail.cpp')
- is_objcxx_test = name.endswith('.mm')
- assert is_sh_test or name_ext == '.cpp' or name_ext == '.mm', \
- 'non-cpp file must be sh test'
-
- if test.config.unsupported:
- return (lit.Test.UNSUPPORTED,
- "A lit.local.cfg marked this unsupported")
-
- if is_objcxx_test and not \
- 'objective-c++' in test.config.available_features:
- return (lit.Test.UNSUPPORTED, "Objective-C++ is not supported")
-
- setattr(test, 'file_dependencies', [])
- parsers = self._make_custom_parsers(test)
- script = lit.TestRunner.parseIntegratedTestScript(
- test, additional_parsers=parsers, require_script=is_sh_test)
-
- # Check if a result for the test was returned. If so return that
- # result.
- if isinstance(script, lit.Test.Result):
- return script
- if lit_config.noExecute:
- return lit.Test.Result(lit.Test.PASS)
-
- # Check that we don't have run lines on tests that don't support them.
- if not is_sh_test and len(script) != 0:
- lit_config.fatal('Unsupported RUN line found in test %s' % name)
-
- tmpDir, tmpBase = lit.TestRunner.getTempPaths(test)
- substitutions = lit.TestRunner.getDefaultSubstitutions(
- test, tmpDir, tmpBase, normalize_slashes=True)
-
- # Apply substitutions in FILE_DEPENDENCIES markup
- data_files = lit.TestRunner.applySubstitutions(test.file_dependencies, substitutions,
- recursion_limit=test.config.recursiveExpansionLimit)
- local_cwd = os.path.dirname(test.getSourcePath())
- data_files = [f if os.path.isabs(f) else os.path.join(local_cwd, f) for f in data_files]
- substitutions.append(('%{file_dependencies}', ' '.join(data_files)))
-
- # Add other convenience substitutions
- substitutions.append(('%{build}', '%{cxx} -o %t.exe %s %{flags} %{compile_flags} %{link_flags}'))
- substitutions.append(('%{run}', '%{exec} %t.exe'))
-
- script = lit.TestRunner.applySubstitutions(script, substitutions,
- recursion_limit=test.config.recursiveExpansionLimit)
-
- test_cxx = copy.deepcopy(self.cxx)
- if is_fail_test:
- test_cxx.useCCache(False)
- test_cxx.useWarnings(False)
- if '-fmodules' in test.config.available_features:
- test_cxx.addWarningFlagIfSupported('-Wno-macro-redefined')
- # FIXME: libc++ debug tests #define _LIBCPP_ASSERT to override it
- # If we see this we need to build the test against uniquely built
- # modules.
- if is_libcxx_test:
- with open(test.getSourcePath(), 'rb') as f:
- contents = f.read()
- if b'#define _LIBCPP_ASSERT' in contents:
- test_cxx.useModules(False)
-
- # Handle ADDITIONAL_COMPILE_FLAGS keywords by adding those compilation
- # flags, but first perform substitutions in those flags.
- extra_compile_flags = self._get_parser('ADDITIONAL_COMPILE_FLAGS:', parsers).getValue()
- extra_compile_flags = lit.TestRunner.applySubstitutions(extra_compile_flags, substitutions)
- test_cxx.compile_flags.extend(extra_compile_flags)
-
- if is_objcxx_test:
- test_cxx.source_lang = 'objective-c++'
- test_cxx.link_flags += ['-framework', 'Foundation']
-
- # Dispatch the test based on its suffix.
- if is_sh_test:
- if not isinstance(self.executor, LocalExecutor) and not isinstance(self.executor, SSHExecutor):
- # We can't run ShTest tests with other executors than
- # LocalExecutor and SSHExecutor yet.
- # For now, bail on trying to run them
- return lit.Test.UNSUPPORTED, 'ShTest format not yet supported'
- test.config.environment = self.executor.merge_environments(os.environ, self.exec_env)
- return lit.TestRunner._runShTest(test, lit_config,
- True, script,
- tmpBase)
- elif is_fail_test:
- return self._evaluate_fail_test(test, test_cxx, parsers)
- elif is_pass_test:
- return self._evaluate_pass_test(test, tmpBase, lit_config,
- test_cxx, parsers, data_files)
- else:
- # No other test type is supported
- assert False
-
- def _clean(self, exec_path): # pylint: disable=no-self-use
- libcxx.util.cleanFile(exec_path)
-
- def _evaluate_pass_test(self, test, tmpBase, lit_config,
- test_cxx, parsers, data_files):
- execDir = os.path.dirname(test.getExecPath())
- source_path = test.getSourcePath()
- exec_path = tmpBase + '.exe'
- object_path = tmpBase + '.o'
- # Create the output directory if it does not already exist.
- libcxx.util.mkdir_p(os.path.dirname(tmpBase))
- try:
- # Compile the test
- cmd, out, err, rc = test_cxx.compileLinkTwoSteps(
- source_path, out=exec_path, object_file=object_path,
- cwd=execDir)
- compile_cmd = cmd
- if rc != 0:
- report = libcxx.util.makeReport(cmd, out, err, rc)
- report += "Compilation failed unexpectedly!"
- return lit.Test.Result(lit.Test.FAIL, report)
- # Run the test
- env = None
- if self.exec_env:
- env = self.exec_env
-
- max_retry = test.allowed_retries + 1
- for retry_count in range(max_retry):
- # Create a temporary directory just for that test and run the
- # test in that directory
- try:
- execDirTmp = tempfile.mkdtemp(dir=execDir)
- cmd, out, err, rc = self.executor.run(exec_path, [exec_path],
- execDirTmp, data_files,
- env)
- finally:
- shutil.rmtree(execDirTmp)
- report = "Compiled With: '%s'\n" % ' '.join(compile_cmd)
- report += libcxx.util.makeReport(cmd, out, err, rc)
- if rc == 0:
- res = lit.Test.PASS if retry_count == 0 else lit.Test.FLAKYPASS
- return lit.Test.Result(res, report)
- elif rc != 0 and retry_count + 1 == max_retry:
- report += "Compiled test failed unexpectedly!"
- return lit.Test.Result(lit.Test.FAIL, report)
-
- assert False # Unreachable
- finally:
- # Note that cleanup of exec_file happens in `_clean()`. If you
- # override this, cleanup is your reponsibility.
- libcxx.util.cleanFile(object_path)
- self._clean(exec_path)
-
- def _evaluate_fail_test(self, test, test_cxx, parsers):
- source_path = test.getSourcePath()
- # FIXME: lift this detection into LLVM/LIT.
- with open(source_path, 'rb') as f:
- contents = f.read()
- verify_tags = [b'expected-note', b'expected-remark',
- b'expected-warning', b'expected-error',
- b'expected-no-diagnostics']
- use_verify = self.use_verify_for_fail and \
- any([tag in contents for tag in verify_tags])
- test_cxx.flags += ['-fsyntax-only']
- if use_verify:
- test_cxx.useVerify()
- cmd, out, err, rc = test_cxx.compile(source_path, out=os.devnull)
- check_rc = lambda rc: rc == 0 if use_verify else rc != 0
- report = libcxx.util.makeReport(cmd, out, err, rc)
- if check_rc(rc):
- return lit.Test.Result(lit.Test.PASS, report)
- else:
- report += ('Expected compilation to fail!\n' if not use_verify else
- 'Expected compilation using verify to pass!\n')
- return lit.Test.Result(lit.Test.FAIL, report)
diff --git a/libcxx/utils/libcxx/test/tracing.py b/libcxx/utils/libcxx/test/tracing.py
deleted file mode 100644
index 0bd339273b68..000000000000
--- a/libcxx/utils/libcxx/test/tracing.py
+++ /dev/null
@@ -1,42 +0,0 @@
-#===----------------------------------------------------------------------===##
-#
-# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-# See https://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#
-#===----------------------------------------------------------------------===##
-
-import os
-import inspect
-
-
-def trace_function(function, log_calls, log_results, label=''):
- def wrapper(*args, **kwargs):
- kwarg_strs = ['{}={}'.format(k, v) for (k, v) in kwargs]
- arg_str = ', '.join([str(a) for a in args] + kwarg_strs)
- call_str = '{}({})'.format(function.__name__, arg_str)
-
- # Perform the call itself, logging before, after, and anything thrown.
- try:
- if log_calls:
- print('{}: Calling {}'.format(label, call_str))
- res = function(*args, **kwargs)
- if log_results:
- print('{}: {} -> {}'.format(label, call_str, res))
- return res
- except Exception as ex:
- if log_results:
- print('{}: {} raised {}'.format(label, call_str, type(ex)))
- raise ex
-
- return wrapper
-
-
-def trace_object(obj, log_calls, log_results, label=''):
- for name, member in inspect.getmembers(obj):
- if inspect.ismethod(member):
- # Skip meta-functions, decorate everything else
- if not member.__name__.startswith('__'):
- setattr(obj, name, trace_function(member, log_calls,
- log_results, label))
- return obj
More information about the libcxx-commits
mailing list