[Lldb-commits] [lldb] r238248 - Also don't try to copy a logfile if it doesn't exist.

Zachary Turner zturner at google.com
Tue May 26 13:26:29 PDT 2015


Author: zturner
Date: Tue May 26 15:26:29 2015
New Revision: 238248

URL: http://llvm.org/viewvc/llvm-project?rev=238248&view=rev
Log:
Also don't try to copy a logfile if it doesn't exist.

In some cases no log file will be written, so don't attempt to
call os.rename() with a non-existent source path.

Modified:
    lldb/trunk/test/lldbtest.py

Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=238248&r1=238247&r2=238248&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Tue May 26 15:26:29 2015
@@ -1566,15 +1566,16 @@ class Base(unittest2.TestCase):
             # keep all log files, rename them to include prefix
             dst_log_basename = self.getLogBasenameForCurrentTest(prefix)
             for src in log_files_for_this_test:
-                dst = src.replace(self.log_basename, dst_log_basename)
-                if os.name == "nt":
-                    # On Windows, renaming a -> b will throw an exception if b exists.  On non-Windows platforms
-                    # it silently replaces the destination.  Ultimately this means that atomic renames are not
-                    # guaranteed to be possible on Windows, but we need this to work anyway, so just remove the
-                    # destination first if it already exists.
-                    os.remove(dst)
+                if os.path.isfile(src):
+                    dst = src.replace(self.log_basename, dst_log_basename)
+                    if os.name == "nt" and os.path.isfile(dst):
+                        # On Windows, renaming a -> b will throw an exception if b exists.  On non-Windows platforms
+                        # it silently replaces the destination.  Ultimately this means that atomic renames are not
+                        # guaranteed to be possible on Windows, but we need this to work anyway, so just remove the
+                        # destination first if it already exists.
+                        os.remove(dst)
 
-                os.rename(src, dst)
+                    os.rename(src, dst)
         else:
             # success!  (and we don't want log files) delete log files
             for log_file in log_files_for_this_test:





More information about the lldb-commits mailing list