Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(649)

Side by Side Diff: testing_support/fake_repos.py

Issue 23437029: Catching for "No such process" in tear_down_git (Closed) Base URL: http://src.chromium.org/svn/trunk/tools/depot_tools/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/checkout_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Generate fake repositories for testing.""" 6 """Generate fake repositories for testing."""
7 7
8 import atexit 8 import atexit
9 import datetime 9 import datetime
10 import errno 10 import errno
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 self.tear_down_git() 235 self.tear_down_git()
236 # This deletes the directories. 236 # This deletes the directories.
237 self.trial.tear_down() 237 self.trial.tear_down()
238 self.trial = None 238 self.trial = None
239 239
240 def tear_down_svn(self): 240 def tear_down_svn(self):
241 if self.svnserve: 241 if self.svnserve:
242 logging.debug('Killing svnserve pid %s' % self.svnserve.pid) 242 logging.debug('Killing svnserve pid %s' % self.svnserve.pid)
243 try: 243 try:
244 self.svnserve.kill() 244 self.svnserve.kill()
245 except OSError, e: 245 except OSError as e:
246 if e.errno != errno.ESRCH: # no such process 246 if e.errno != errno.ESRCH: # no such process
247 raise 247 raise
248 wait_for_port_to_free(self.host, self.svn_port) 248 wait_for_port_to_free(self.host, self.svn_port)
249 self.svnserve = None 249 self.svnserve = None
250 self.svn_port = None 250 self.svn_port = None
251 self.svn_base = None 251 self.svn_base = None
252 if not self.trial.SHOULD_LEAK: 252 if not self.trial.SHOULD_LEAK:
253 logging.debug('Removing %s' % self.svn_repo) 253 logging.debug('Removing %s' % self.svn_repo)
254 gclient_utils.rmtree(self.svn_repo) 254 gclient_utils.rmtree(self.svn_repo)
255 logging.debug('Removing %s' % self.svn_checkout) 255 logging.debug('Removing %s' % self.svn_checkout)
256 gclient_utils.rmtree(self.svn_checkout) 256 gclient_utils.rmtree(self.svn_checkout)
257 else: 257 else:
258 return False 258 return False
259 return True 259 return True
260 260
261 def tear_down_git(self): 261 def tear_down_git(self):
262 if self.gitdaemon: 262 if self.gitdaemon:
263 logging.debug('Killing git-daemon pid %s' % self.gitdaemon.pid) 263 logging.debug('Killing git-daemon pid %s' % self.gitdaemon.pid)
264 self.gitdaemon.kill() 264 self.gitdaemon.kill()
265 self.gitdaemon = None 265 self.gitdaemon = None
266 if self.git_pid_file: 266 if self.git_pid_file:
267 pid = int(self.git_pid_file.read()) 267 pid = int(self.git_pid_file.read())
268 self.git_pid_file.close() 268 self.git_pid_file.close()
269 logging.debug('Killing git daemon pid %s' % pid) 269 logging.debug('Killing git daemon pid %s' % pid)
270 subprocess2.kill_pid(pid) 270 try:
271 subprocess2.kill_pid(pid)
272 except OSError as e:
273 if e.errno != errno.ESRCH: # no such process
274 raise
271 self.git_pid_file = None 275 self.git_pid_file = None
272 wait_for_port_to_free(self.host, self.git_port) 276 wait_for_port_to_free(self.host, self.git_port)
273 self.git_port = None 277 self.git_port = None
274 self.git_base = None 278 self.git_base = None
275 if not self.trial.SHOULD_LEAK: 279 if not self.trial.SHOULD_LEAK:
276 logging.debug('Removing %s' % self.git_root) 280 logging.debug('Removing %s' % self.git_root)
277 gclient_utils.rmtree(self.git_root) 281 gclient_utils.rmtree(self.git_root)
278 else: 282 else:
279 return False 283 return False
280 return True 284 return True
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 fake.set_up_git() 804 fake.set_up_git()
801 print('Fake setup, press enter to quit or Ctrl-C to keep the checkouts.') 805 print('Fake setup, press enter to quit or Ctrl-C to keep the checkouts.')
802 sys.stdin.readline() 806 sys.stdin.readline()
803 except KeyboardInterrupt: 807 except KeyboardInterrupt:
804 trial_dir.TrialDir.SHOULD_LEAK.leak = True 808 trial_dir.TrialDir.SHOULD_LEAK.leak = True
805 return 0 809 return 0
806 810
807 811
808 if __name__ == '__main__': 812 if __name__ == '__main__':
809 sys.exit(main(sys.argv)) 813 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | tests/checkout_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698