Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 """Compare the artifacts from two builds.""" | 5 """Compare the artifacts from two builds.""" |
| 6 | 6 |
| 7 import filecmp | 7 import filecmp |
| 8 import json | 8 import json |
| 9 import optparse | 9 import optparse |
| 10 import os | 10 import os |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 res = 0 | 48 res = 0 |
| 49 first_list = get_files_to_compare(first_dir) - blacklist | 49 first_list = get_files_to_compare(first_dir) - blacklist |
| 50 second_list = get_files_to_compare(second_dir) - blacklist | 50 second_list = get_files_to_compare(second_dir) - blacklist |
| 51 | 51 |
| 52 diff = first_list.symmetric_difference(second_list) | 52 diff = first_list.symmetric_difference(second_list) |
| 53 if diff: | 53 if diff: |
| 54 print >> sys.stderr, 'Different list of files in both directories' | 54 print >> sys.stderr, 'Different list of files in both directories' |
| 55 print >> sys.stderr, '\n'.join(' ' + i for i in sorted(diff)) | 55 print >> sys.stderr, '\n'.join(' ' + i for i in sorted(diff)) |
| 56 res = 1 | 56 res = 1 |
| 57 | 57 |
| 58 cmp_results = [] | |
| 58 for f in first_list & second_list: | 59 for f in first_list & second_list: |
|
M-A Ruel
2014/10/23 20:32:05
for f in sorted(first_list & second_list):
then r
Sébastien Marchand
2014/10/23 20:38:17
Of course...
| |
| 59 first_file = os.path.join(first_dir, f) | 60 first_file = os.path.join(first_dir, f) |
| 60 second_file = os.path.join(second_dir, f) | 61 second_file = os.path.join(second_dir, f) |
| 61 if filecmp.cmp(first_file, second_file, shallow=False): | 62 if filecmp.cmp(first_file, second_file, shallow=False): |
| 62 print('%s: equal' % f) | 63 cmp_results.append('%s: equal' % f) |
| 63 else: | 64 else: |
| 64 print('%s: DIFFERENT' % f) | 65 cmp_results.append('%s: DIFFERENT' % f) |
| 65 res = 1 | 66 res = 1 |
| 66 | 67 |
| 68 print '\n'.join(i for i in sorted(cmp_results)) | |
| 69 | |
| 67 return res | 70 return res |
| 68 | 71 |
| 69 | 72 |
| 70 def main(): | 73 def main(): |
| 71 parser = optparse.OptionParser(usage='%prog [options]') | 74 parser = optparse.OptionParser(usage='%prog [options]') |
| 72 parser.add_option('--first-build-dir', help='The first build directory.') | 75 parser.add_option('--first-build-dir', help='The first build directory.') |
| 73 parser.add_option('--second-build-dir', help='The second build directory.') | 76 parser.add_option('--second-build-dir', help='The second build directory.') |
| 74 options, _ = parser.parse_args() | 77 options, _ = parser.parse_args() |
| 75 | 78 |
| 76 if not options.first_build_dir: | 79 if not options.first_build_dir: |
| 77 parser.error('--first-build-dir is required') | 80 parser.error('--first-build-dir is required') |
| 78 if not options.second_build_dir: | 81 if not options.second_build_dir: |
| 79 parser.error('--second-build-dir is required') | 82 parser.error('--second-build-dir is required') |
| 80 | 83 |
| 81 return compare_build_artifacts(options.first_build_dir, | 84 return compare_build_artifacts(options.first_build_dir, |
| 82 options.second_build_dir) | 85 options.second_build_dir) |
| 83 | 86 |
| 84 | 87 |
| 85 if __name__ == '__main__': | 88 if __name__ == '__main__': |
| 86 sys.exit(main()) | 89 sys.exit(main()) |
| OLD | NEW |