forked from OSchip/llvm-project
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. llvm-svn: 238248
This commit is contained in:
parent
3c36b324dc
commit
306278ff0d
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue