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

Side by Side Diff: testing_support/trial_dir.py

Issue 14134010: Remove gclient_utils.RemoveDirectory(). (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: RemoveDirectory() -> rmtree() Created 7 years, 8 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
« no previous file with comments | « scm.py ('k') | tests/gclient_scm_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 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 5
6 import atexit 6 import atexit
7 import logging 7 import logging
8 import os 8 import os
9 import sys 9 import sys
10 import tempfile 10 import tempfile
(...skipping 25 matching lines...) Expand all
36 self.root_dir = None 36 self.root_dir = None
37 37
38 def set_up(self): 38 def set_up(self):
39 """All late initialization comes here.""" 39 """All late initialization comes here."""
40 # You can override self.TRIAL_ROOT. 40 # You can override self.TRIAL_ROOT.
41 if not self.TRIAL_ROOT: 41 if not self.TRIAL_ROOT:
42 # Was not yet initialized. 42 # Was not yet initialized.
43 TrialDir.TRIAL_ROOT = os.path.realpath(tempfile.mkdtemp(prefix='trial')) 43 TrialDir.TRIAL_ROOT = os.path.realpath(tempfile.mkdtemp(prefix='trial'))
44 atexit.register(self._clean) 44 atexit.register(self._clean)
45 self.root_dir = os.path.join(TrialDir.TRIAL_ROOT, self.subdir) 45 self.root_dir = os.path.join(TrialDir.TRIAL_ROOT, self.subdir)
46 gclient_utils.RemoveDirectory(self.root_dir) 46 gclient_utils.rmtree(self.root_dir)
47 os.makedirs(self.root_dir) 47 os.makedirs(self.root_dir)
48 48
49 def tear_down(self): 49 def tear_down(self):
50 """Cleans the trial subdirectory for this instance.""" 50 """Cleans the trial subdirectory for this instance."""
51 if not self.leak: 51 if not self.leak:
52 logging.debug('Removing %s' % self.root_dir) 52 logging.debug('Removing %s' % self.root_dir)
53 gclient_utils.RemoveDirectory(self.root_dir) 53 gclient_utils.rmtree(self.root_dir)
54 else: 54 else:
55 logging.error('Leaking %s' % self.root_dir) 55 logging.error('Leaking %s' % self.root_dir)
56 self.root_dir = None 56 self.root_dir = None
57 57
58 @staticmethod 58 @staticmethod
59 def _clean(): 59 def _clean():
60 """Cleans the root trial directory.""" 60 """Cleans the root trial directory."""
61 if not TrialDir.SHOULD_LEAK: 61 if not TrialDir.SHOULD_LEAK:
62 logging.debug('Removing %s' % TrialDir.TRIAL_ROOT) 62 logging.debug('Removing %s' % TrialDir.TRIAL_ROOT)
63 gclient_utils.RemoveDirectory(TrialDir.TRIAL_ROOT) 63 gclient_utils.rmtree(TrialDir.TRIAL_ROOT)
64 else: 64 else:
65 logging.error('Leaking %s' % TrialDir.TRIAL_ROOT) 65 logging.error('Leaking %s' % TrialDir.TRIAL_ROOT)
66 66
67 67
68 class TrialDirMixIn(object): 68 class TrialDirMixIn(object):
69 def setUp(self): 69 def setUp(self):
70 # Create a specific directory just for the test. 70 # Create a specific directory just for the test.
71 self.trial = TrialDir(self.id()) 71 self.trial = TrialDir(self.id())
72 self.trial.set_up() 72 self.trial.set_up()
73 73
(...skipping 14 matching lines...) Expand all
88 def tearDown(self): 88 def tearDown(self):
89 TrialDirMixIn.tearDown(self) 89 TrialDirMixIn.tearDown(self)
90 auto_stub.TestCase.tearDown(self) 90 auto_stub.TestCase.tearDown(self)
91 91
92 92
93 if '-l' in sys.argv: 93 if '-l' in sys.argv:
94 # See SHOULD_LEAK definition in TrialDir for its purpose. 94 # See SHOULD_LEAK definition in TrialDir for its purpose.
95 TrialDir.SHOULD_LEAK = True 95 TrialDir.SHOULD_LEAK = True
96 print 'Leaking!' 96 print 'Leaking!'
97 sys.argv.remove('-l') 97 sys.argv.remove('-l')
OLDNEW
« no previous file with comments | « scm.py ('k') | tests/gclient_scm_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698