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
|
# keep all log files, rename them to include prefix
|
||||||
dst_log_basename = self.getLogBasenameForCurrentTest(prefix)
|
dst_log_basename = self.getLogBasenameForCurrentTest(prefix)
|
||||||
for src in log_files_for_this_test:
|
for src in log_files_for_this_test:
|
||||||
dst = src.replace(self.log_basename, dst_log_basename)
|
if os.path.isfile(src):
|
||||||
if os.name == "nt":
|
dst = src.replace(self.log_basename, dst_log_basename)
|
||||||
# On Windows, renaming a -> b will throw an exception if b exists. On non-Windows platforms
|
if os.name == "nt" and os.path.isfile(dst):
|
||||||
# it silently replaces the destination. Ultimately this means that atomic renames are not
|
# On Windows, renaming a -> b will throw an exception if b exists. On non-Windows platforms
|
||||||
# guaranteed to be possible on Windows, but we need this to work anyway, so just remove the
|
# it silently replaces the destination. Ultimately this means that atomic renames are not
|
||||||
# destination first if it already exists.
|
# guaranteed to be possible on Windows, but we need this to work anyway, so just remove the
|
||||||
os.remove(dst)
|
# destination first if it already exists.
|
||||||
|
os.remove(dst)
|
||||||
|
|
||||||
os.rename(src, dst)
|
os.rename(src, dst)
|
||||||
else:
|
else:
|
||||||
# success! (and we don't want log files) delete log files
|
# success! (and we don't want log files) delete log files
|
||||||
for log_file in log_files_for_this_test:
|
for log_file in log_files_for_this_test:
|
||||||
|
|
Loading…
Reference in New Issue