Fix test_attach_to_process_from_different_dir_by_id test on Windows

On Windows a process can't delete its own current direcotry, that's why the test
needs to return to the original direcotry before removing newdir.

llvm-svn: 313113
This commit is contained in:
Eugene Zemtsov 2017-09-13 02:44:24 +00:00
parent 0a3bcebcc2
commit a2aa64760d
1 changed files with 6 additions and 3 deletions

View File

@ -46,15 +46,18 @@ class ProcessAttachTestCase(TestBase):
except OSError, e:
if e.errno != os.errno.EEXIST:
raise
self.buildProgram('main.cpp',os.path.join(os.getcwd(),'newdir','proc_attach'))
exe = os.path.join('.','newdir','proc_attach')
self.addTearDownHook(lambda: shutil.rmtree(os.path.join(os.getcwd())))
testdir = os.getcwd()
newdir = os.path.join(testdir,'newdir')
exe = os.path.join(newdir, 'proc_attach')
self.buildProgram('main.cpp', exe)
self.addTearDownHook(lambda: shutil.rmtree(newdir))
# Spawn a new process
popen = self.spawnSubprocess(exe)
self.addTearDownHook(self.cleanupSubprocesses)
os.chdir('newdir')
self.addTearDownHook(lambda: os.chdir(testdir))
self.runCmd("process attach -p " + str(popen.pid))
target = self.dbg.GetSelectedTarget()