Skip to content

Commit

Permalink
We need sudo in test directory
Browse files Browse the repository at this point in the history
Use shutil instead of subprocess where possible
  • Loading branch information
reikdas committed Feb 6, 2021
1 parent 6ab5330 commit e5761cc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 5 additions & 3 deletions test/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import os
import sys
import platform
import re
import shutil
import subprocess

import lit.util
Expand Down Expand Up @@ -329,14 +330,15 @@ if not os.path.exists(os.path.join(config.test_exec_root, "..", "..", "clang", "
branch_ref = subprocess.check_output(["git", "ls-remote", "https://github.com/llvm/llvm-project.git", "release/{0}.x".format(branch_vers)], stderr=subprocess.STDOUT).decode()
commit = branch_ref[:branch_ref.find("\trefs/heads")]
# We get zip instead of git clone to not download git history
subprocess.Popen(['wget https://github.com/llvm/llvm-project/archive/{0}.zip && \
unzip {0}.zip "llvm-project-{0}/llvm/utils/lit/*" && mkdir utils/ && \
mv llvm-project-{0}/llvm/utils/lit/ utils/'.format(commit)],
subprocess.Popen(['sudo wget https://github.com/llvm/llvm-project/archive/{0}.zip && \
sudo unzip {0}.zip "llvm-project-{0}/llvm/utils/lit/*"'.format(commit)],
cwd=config.llvm_src_root,
shell=True,
stdin=subprocess.PIPE,
stdout=None,
stderr=subprocess.STDOUT).communicate('yes'.encode('utf-8'))
os.mkdir(os.path.join(config.llvm_src_root, "utils"))
shutil.move(os.path.join(config.llvm_src_root, "llvm-project-{0}".format(commit), "llvm", "utils", "lit"), os.path.join(config.llvm_src_root, "utils", "lit"))
config.substitutions.append(('%testexecdir', config.test_exec_root))
config.substitutions.append(('%llvmsrcdir', config.llvm_src_root))
config.available_features.add('vanilla-cling')
Expand Down
8 changes: 7 additions & 1 deletion tools/packaging/cpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,13 @@ def build_filecheck():
branch_ref = subprocess.check_output(["git", "ls-remote", "https://github.com/llvm/llvm-project.git", "release/{0}.x".format(branch_vers)], stderr=subprocess.STDOUT).decode()
commit = branch_ref[:branch_ref.find("\trefs/heads")]
# We get zip instead of git clone to not download git history
subprocess.Popen(['wget https://github.com/llvm/llvm-project/archive/{0}.zip && unzip {0}.zip "llvm-project-{0}/llvm/utils/*" && mv llvm-project-{0}/llvm/utils/FileCheck FileCheck'.format(commit)], cwd=os.path.join(CLING_SRC_DIR, "tools"), shell=True, stdin=subprocess.PIPE, stdout=None, stderr=subprocess.STDOUT).communicate('yes'.encode('utf-8'))
subprocess.Popen(['wget https://github.com/llvm/llvm-project/archive/{0}.zip && unzip {0}.zip "llvm-project-{0}/llvm/utils/*"'.format(commit)],
cwd=os.path.join(CLING_SRC_DIR, "tools"),
shell=True,
stdin=subprocess.PIPE,
stdout=None,
stderr=subprocess.STDOUT).communicate('yes'.encode('utf-8'))
shutil.move(os.path.join(CLING_SRC_DIR, "tools", "llvm-project-{0}".format(commit), "llvm", "utils", "FileCheck"), os.path.join(CLING_SRC_DIR, "tools", "FileCheck"))
with open(os.path.join(CLING_SRC_DIR, 'tools', 'CMakeLists.txt'), 'a') as file:
file.writelines('add_subdirectory(\"FileCheck\")')
exec_subprocess_call("cmake {0}".format(LLVM_OBJ_ROOT), CLING_SRC_DIR)
Expand Down

0 comments on commit e5761cc

Please sign in to comment.