[clang] 9c7ff0a - [analyzer][tests] Make test interruption safe

Valeriy Savchenko via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 10 01:33:19 PDT 2020


Author: Valeriy Savchenko
Date: 2020-07-10T11:31:59+03:00
New Revision: 9c7ff0a4aaef0a1efa33e9ff8a12a064087bded9

URL: https://github.com/llvm/llvm-project/commit/9c7ff0a4aaef0a1efa33e9ff8a12a064087bded9
DIFF: https://github.com/llvm/llvm-project/commit/9c7ff0a4aaef0a1efa33e9ff8a12a064087bded9.diff

LOG: [analyzer][tests] Make test interruption safe

Differential Revision: https://reviews.llvm.org/D83373

Added: 
    

Modified: 
    clang/utils/analyzer/SATest.py

Removed: 
    


################################################################################
diff  --git a/clang/utils/analyzer/SATest.py b/clang/utils/analyzer/SATest.py
index fb2e031c6ab6..16f1dce0c584 100755
--- a/clang/utils/analyzer/SATest.py
+++ b/clang/utils/analyzer/SATest.py
@@ -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():


        


More information about the cfe-commits mailing list