From: Louis Dionne Date: Tue, 7 Apr 2020 19:42:00 +0000 (-0400) Subject: [libc++] Run tests in a directory related to %t instead of /tmp X-Git-Tag: llvmorg-12-init~9761 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3fefda6e578b431875405791bc7216595d767fbf;p=platform%2Fupstream%2Fllvm.git [libc++] Run tests in a directory related to %t instead of /tmp Instead of creating a temporary directory inside /tmp and running the tests there, use a directory name based on LIT's %t substitution. This has the benefit of not hitting /tmp so much (which is slow on some filesystems). It also has the benefit that `ninja -C build clean` will automatically remove the artifacts even if a test somehow failed to remove its temporary directory (I've seen this happen when CTRL-C is received). --- diff --git a/libcxx/utils/libcxx/test/config.py b/libcxx/utils/libcxx/test/config.py index e3a4820..f86a796 100644 --- a/libcxx/utils/libcxx/test/config.py +++ b/libcxx/utils/libcxx/test/config.py @@ -1064,6 +1064,7 @@ class Configuration(object): exec_args.append('--host {}'.format(self.executor.user_prefix + self.executor.host)) executor = os.path.join(self.libcxx_src_root, 'utils', 'ssh.py') else: + exec_args.append('--execdir %t.execdir') executor = os.path.join(self.libcxx_src_root, 'utils', 'run.py') sub.append(('%{exec}', '{} {} {} -- '.format(pipes.quote(sys.executable), pipes.quote(executor), diff --git a/libcxx/utils/run.py b/libcxx/utils/run.py index 3290416..8c3eaeb 100644 --- a/libcxx/utils/run.py +++ b/libcxx/utils/run.py @@ -17,11 +17,11 @@ import os import shutil import subprocess import sys -import tempfile def main(): parser = argparse.ArgumentParser() + parser.add_argument('--execdir', type=str, required=True) parser.add_argument('--codesign_identity', type=str, required=False, default=None) parser.add_argument('--dependencies', type=str, nargs='*', required=False, default=[]) parser.add_argument('--env', type=str, nargs='*', required=False, default=dict()) @@ -43,23 +43,25 @@ def main(): # Extract environment variables into a dictionary env = {k : v for (k, v) in map(lambda s: s.split('=', 1), args.env)} + # Create the execution directory, and make sure we remove it at the end. try: - tmpDir = tempfile.mkdtemp() + os.mkdir(args.execdir) - # Ensure the file dependencies exist and copy them to a temporary directory. + # Ensure the file dependencies exist and copy them to the execution directory. for dep in args.dependencies: if not os.path.exists(dep): sys.stderr.write('Missing file or directory "{}" marked as a dependency of a test'.format(dep)) exit(1) if os.path.isdir(dep): - shutil.copytree(dep, os.path.join(tmpDir, os.path.basename(dep)), symlinks=True) + shutil.copytree(dep, os.path.join(args.execdir, os.path.basename(dep)), symlinks=True) else: - shutil.copy2(dep, tmpDir) + shutil.copy2(dep, args.execdir) - # Run the executable with the given environment in the temporary directory. - return subprocess.call(' '.join(remaining), cwd=tmpDir, env=env, shell=True) + # Run the executable with the given environment in the execution directory. + return subprocess.call(' '.join(remaining), cwd=args.execdir, env=env, shell=True) finally: - shutil.rmtree(tmpDir) + shutil.rmtree(args.execdir) + if __name__ == '__main__': exit(main())