Add a mkdir -p to builddir into lldbtest.py
authorAdrian Prantl <aprantl@apple.com>
Mon, 27 Aug 2018 23:06:37 +0000 (23:06 +0000)
committerAdrian Prantl <aprantl@apple.com>
Mon, 27 Aug 2018 23:06:37 +0000 (23:06 +0000)
Based on how it is executed, it may not have been yet created.

llvm-svn: 340791

lldb/lit/Suite/lldbtest.py

index 61e9ceb..d09246e 100644 (file)
@@ -18,6 +18,16 @@ def getBuildDir(cmd):
             found = True
     return None
 
+def mkdir_p(path):
+    import errno
+    try:
+        os.makedirs(path)
+    except OSError as e:
+        if e.errno != errno.EEXIST:
+            raise
+    if not os.path.isdir(path):
+        raise OSError(errno.ENOTDIR, "%s is not a directory"%path)
+
 class LLDBTest(TestFormat):
     def __init__(self, dotest_cmd):
         self.dotest_cmd = dotest_cmd
@@ -64,6 +74,7 @@ class LLDBTest(TestFormat):
                 sys.executable.startswith('/System/'):
             builddir = getBuildDir(cmd)
             assert(builddir)
+            mkdir_p(builddir)
             copied_python = os.path.join(builddir, 'copied-system-python')
             import shutil
             shutil.copy(sys.executable, os.path.join(builddir, copied_python))