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('--working_directory "%S"')
executor = os.path.join(self.libcxx_src_root, 'utils', 'run.py')
sub.append(('%{exec}', '{} {} {} -- '.format(pipes.quote(sys.executable),
pipes.quote(executor),
import os
import posixpath
import ntpath
+import shutil
from libcxx.test import tracing
from libcxx.util import executeCommand
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)
import copy
import errno
import os
+import shutil
+import tempfile
import time
import random
report += "Compilation failed unexpectedly!"
return lit.Test.Result(lit.Test.FAIL, report)
# Run the test
- local_cwd = os.path.dirname(source_path)
env = None
if self.exec_env:
env = self.exec_env
max_retry = test.allowed_retries + 1
for retry_count in range(max_retry):
- cmd, out, err, rc = self.executor.run(exec_path, [exec_path],
- local_cwd, data_files,
- env)
+ # 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:
import argparse
import os
+import shutil
import subprocess
import sys
+import tempfile
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--codesign_identity', type=str, required=False)
- parser.add_argument('--working_directory', type=str, required=True)
parser.add_argument('--dependencies', type=str, nargs='*', required=True)
parser.add_argument('--env', type=str, nargs='*', required=True)
(args, remaining) = parser.parse_known_args(sys.argv[1:])
# Extract environment variables into a dictionary
env = {k : v for (k, v) in map(lambda s: s.split('=', 1), args.env)}
- # Ensure the file dependencies exist
- for file in args.dependencies:
- if not os.path.exists(file):
- sys.stderr.write('Missing file {} marked as a dependency of a test'.format(file))
- exit(1)
+ try:
+ tmpDir = tempfile.mkdtemp()
- # Run the executable with the given environment in the given working directory
- return subprocess.call(' '.join(remaining), cwd=args.working_directory, env=env, shell=True)
+ # Ensure the file dependencies exist and copy them to a temporary 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)
+ else:
+ shutil.copy2(dep, tmpDir)
+
+ # Run the executable with the given environment in the temporary directory.
+ return subprocess.call(' '.join(remaining), cwd=tmpDir, env=env, shell=True)
+ finally:
+ shutil.rmtree(tmpDir)
if __name__ == '__main__':
exit(main())