[analyzer][tests] Make test interruption safe

Differential Revision: https://reviews.llvm.org/D83373
This commit is contained in:
Valeriy Savchenko 2020-07-10 11:20:20 +03:00
parent 21bacc2154
commit 9c7ff0a4aa
1 changed files with 26 additions and 18 deletions

View File

@ -132,27 +132,35 @@ def docker_shell(args):
pass
finally:
print("Please wait for docker to clean up")
call("docker stop satest", shell=True)
docker_cleanup()
def docker_run(args, command, docker_args=""):
return call("docker run --rm --name satest "
"-v {llvm}:/llvm-project "
"-v {build}:/build "
"-v {clang}:/analyzer "
"-v {scripts}:/scripts "
"-v {projects}:/projects "
"{docker_args} "
"satest-image:latest {command}"
.format(llvm=args.llvm_project_dir,
build=args.build_dir,
clang=args.clang_dir,
scripts=SCRIPTS_DIR,
projects=PROJECTS_DIR,
docker_args=docker_args,
command=command),
shell=True)
try:
return call("docker run --rm --name satest "
"-v {llvm}:/llvm-project "
"-v {build}:/build "
"-v {clang}:/analyzer "
"-v {scripts}:/scripts "
"-v {projects}:/projects "
"{docker_args} "
"satest-image:latest {command}"
.format(llvm=args.llvm_project_dir,
build=args.build_dir,
clang=args.clang_dir,
scripts=SCRIPTS_DIR,
projects=PROJECTS_DIR,
docker_args=docker_args,
command=command),
shell=True)
except KeyboardInterrupt:
docker_cleanup()
def docker_cleanup():
print("Please wait for docker to clean up")
call("docker stop satest", shell=True)
def main():