def create_isolate_tree(outdir, root_dir, files, relative_cwd, read_only): """Creates a isolated tree usable for test execution. Returns the current working directory where the isolated command should be started in. """ # Forcibly copy when the tree has to be read only. Otherwise the inode is # modified, and this cause real problems because the user's source tree # becomes read only. On the other hand, the cost of doing file copy is huge. if read_only not in (0, None): action = file_path.COPY else: action = file_path.HARDLINK_WITH_FALLBACK recreate_tree(outdir=outdir, indir=root_dir, infiles=files, action=action, as_hash=False) cwd = os.path.normpath(os.path.join(outdir, relative_cwd)) # cwd may not exist when no files are mapped from the directory containing the # .isolate file. But the directory must exist to be the current working # directory. file_path.ensure_tree(cwd) run_isolated.change_tree_read_only(outdir, read_only) return cwd
def create_isolate_tree(outdir, root_dir, files, relative_cwd, read_only): """Creates a isolated tree usable for test execution. Returns the current working directory where the isolated command should be started in. """ # Forcibly copy when the tree has to be read only. Otherwise the inode is # modified, and this cause real problems because the user's source tree # becomes read only. On the other hand, the cost of doing file copy is huge. if read_only not in (0, None): action = file_path.COPY else: action = file_path.HARDLINK_WITH_FALLBACK recreate_tree( outdir=outdir, indir=root_dir, infiles=files, action=action, as_hash=False) cwd = os.path.normpath(os.path.join(outdir, relative_cwd)) if not os.path.isdir(cwd): # It can happen when no files are mapped from the directory containing the # .isolate file. But the directory must exist to be the current working # directory. os.makedirs(cwd) run_isolated.change_tree_read_only(outdir, read_only) return cwd