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

Side by Side Diff: scripts/slave/recipe_modules/isolate/resources/find_isolated_tests.py

Issue 620703002: Add isolate.clean_isolated_files and use in all related recipes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 6 years, 2 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 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 """Scans build output directory for .isolated files, calculates their SHA1 6 """Scans build output directory for .isolated files, calculates their SHA1
7 hashes and stores final list in JSON document. 7 hashes and stores final list in JSON document.
8 8
9 Used to figure out what tests were build in isolated mode to trigger these 9 Used to figure out what tests were build in isolated mode to trigger these
10 tests to run on swarming. 10 tests to run on swarming.
(...skipping 18 matching lines...) Expand all
29 while True: 29 while True:
30 chunk = f.read(1024*1024) 30 chunk = f.read(1024*1024)
31 if not chunk: 31 if not chunk:
32 break 32 break
33 digest.update(chunk) 33 digest.update(chunk)
34 return digest.hexdigest() 34 return digest.hexdigest()
35 35
36 36
37 def main(): 37 def main():
38 parser = optparse.OptionParser( 38 parser = optparse.OptionParser(
39 usage='%prog --build-dir <path> --output-json <path>', 39 usage='%prog --build-dir <path> '
40 '[--output-json <path> | --clean-isolated-files]',
40 description=sys.modules[__name__].__doc__) 41 description=sys.modules[__name__].__doc__)
41 parser.add_option( 42 parser.add_option(
42 '--build-dir', 43 '--build-dir',
43 help='Path to a directory to search for *.isolated files.') 44 help='Path to a directory to search for *.isolated files.')
44 parser.add_option( 45 parser.add_option(
45 '--output-json', 46 '--output-json',
46 help='File to dump JSON results into.') 47 help='File to dump JSON results into. '
48 'Mutually exclusive with --clean-isolated-files.')
49 parser.add_option(
50 '--clean-isolated-files',
51 action='store_true',
52 help='Whether to clean out all .isolated files. '
53 'Mutually exclusive with --output-json.')
47 54
48 options, _ = parser.parse_args() 55 options, _ = parser.parse_args()
49 if not options.build_dir: 56 if not options.build_dir:
50 parser.error('--build-dir option is required') 57 parser.error('--build-dir option is required')
51 if not options.output_json: 58 if not (options.output_json or options.clean_isolated_files):
52 parser.error('--output-json option is required') 59 parser.error('either --output-json or --clean-isolated-files is required')
60 if options.output_json and options.clean_isolated_files:
61 parser.error('only one of --output-json and '
62 '--clean-isolated-files is allowed')
53 63
54 result = {} 64 result = {}
55 65
56 # Get the file hash values and output the pair. 66 # Get the file hash values and output the pair.
57 pattern = os.path.join(options.build_dir, '*.isolated') 67 pattern = os.path.join(options.build_dir, '*.isolated')
58 for filepath in sorted(glob.glob(pattern)): 68 for filepath in sorted(glob.glob(pattern)):
59 test_name = os.path.splitext(os.path.basename(filepath))[0] 69 test_name = os.path.splitext(os.path.basename(filepath))[0]
60 if re.match(r'^.+?\.\d$', test_name): 70 if re.match(r'^.+?\.\d$', test_name):
61 # It's a split .isolated file, e.g. foo.0.isolated. Ignore these. 71 # It's a split .isolated file, e.g. foo.0.isolated. Ignore these.
62 continue 72 continue
63 73
64 sha1_hash = hash_file(filepath) 74 if options.clean_isolated_files:
65 result[test_name] = sha1_hash 75 # TODO(csharp): Remove deletion entirely once the isolate
76 # tracked dependencies are inputs for the isolated files.
77 # http://crbug.com/419031
78 os.remove(filepath)
79 else:
80 sha1_hash = hash_file(filepath)
81 result[test_name] = sha1_hash
66 82
67 with open(options.output_json, 'wb') as f: 83 if options.output_json:
68 json.dump(result, f) 84 with open(options.output_json, 'wb') as f:
85 json.dump(result, f)
69 86
70 return 0 87 return 0
71 88
72 89
73 if __name__ == '__main__': 90 if __name__ == '__main__':
74 sys.exit(main()) 91 sys.exit(main())
OLDNEW
« no previous file with comments | « scripts/slave/recipe_modules/isolate/api.py ('k') | scripts/slave/recipes/chromium.expected/dynamic_swarmed_gtest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698