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

Side by Side Diff: tools/isolate/run_test_from_archive.py

Issue 10382239: Cleanup Cache Stored State (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 7 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 | « no previous file | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 """Reads a manifest, creates a tree of hardlinks and runs the test. 6 """Reads a manifest, creates a tree of hardlinks and runs the test.
7 7
8 Keeps a local cache. 8 Keeps a local cache.
9 """ 9 """
10 10
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 if os.path.isfile(self.state_file): 168 if os.path.isfile(self.state_file):
169 try: 169 try:
170 self.state = json.load(open(self.state_file, 'rb')) 170 self.state = json.load(open(self.state_file, 'rb'))
171 except ValueError: 171 except ValueError:
172 # Too bad. The file will be overwritten and the cache cleared. 172 # Too bad. The file will be overwritten and the cache cleared.
173 pass 173 pass
174 self.trim() 174 self.trim()
175 175
176 def trim(self): 176 def trim(self):
177 """Trims anything we don't know, make sure enough free space exists.""" 177 """Trims anything we don't know, make sure enough free space exists."""
178 # Ensure that all files listed in the state still exist.
179 for f in self.state:
180 if not os.path.exists(os.path.join(self.cache_dir, f)):
181 self.state.remove(f)
182
178 for f in os.listdir(self.cache_dir): 183 for f in os.listdir(self.cache_dir):
179 if f == self.STATE_FILE or f in self.state: 184 if f == self.STATE_FILE or f in self.state:
180 continue 185 continue
181 logging.warn('Unknown file %s from cache' % f) 186 logging.warn('Unknown file %s from cache' % f)
182 # Insert as the oldest file. It will be deleted eventually if not 187 # Insert as the oldest file. It will be deleted eventually if not
183 # accessed. 188 # accessed.
184 self.state.insert(0, f) 189 self.state.insert(0, f)
185 190
186 # Ensure enough free space. 191 # Ensure enough free space.
187 while ( 192 while (
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 parser.error('Unsupported args %s' % ' '.join(args)) 320 parser.error('Unsupported args %s' % ' '.join(args))
316 321
317 manifest = json.load(open_remote(options.manifest)) 322 manifest = json.load(open_remote(options.manifest))
318 return run_tha_test( 323 return run_tha_test(
319 manifest, os.path.abspath(options.cache), options.remote, 324 manifest, os.path.abspath(options.cache), options.remote,
320 options.max_cache_size, options.min_free_space) 325 options.max_cache_size, options.min_free_space)
321 326
322 327
323 if __name__ == '__main__': 328 if __name__ == '__main__':
324 sys.exit(main()) 329 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698